Skip to content

Read input symlinks for stdout and read-only modes - #5044

Merged
jlee303 merged 4 commits into
devfrom
fix-issue-3627
Nov 30, 2026
Merged

jlee303 merged 4 commits into
devfrom
fix-issue-3627

Conversation

@jlee303

@jlee303 jlee303 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What and why

Addresses #3627

  • This PR is based on @Jacob-Met's original fix from his fork. CLI now reads input symlinks without requiring -f when writing to stdout. When writing an output file to disk or with -r, it still refuses symlinks.
  • Added test cases to verify changes
  • Updated docs to include section on symlinks

Checklist

  • I searched open pull requests and issues: this problem is not already being addressed.
  • Bug fix: it comes with a reproducer or a test that fails without the fix.
  • Performance change: numbers from repeated runs are included, with CPU, compiler, flags and data.
    A gain in one configuration is not a general gain: see the Performance section of CONTRIBUTING.md.
  • I stated below whether AI or other automated tools were used.

Tools used
Use Claude to review original PR fix

@jlee303
jlee303 marked this pull request as ready for review November 25, 2026 20:44

@Cyan4973 Cyan4973 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good to me.

I built dev and this branch, and compared them on symbolic links given on the command line:

  • -c, -dc, -t and -l now follow the link. --rm -c keeps both the link and its target, since --rm is ignored when the output is stdout.
  • When a file would be written (zstd link, -o out link, -d link.zst), the link is still refused. So is -r, even with -c, and links inside a directory are still skipped.
  • A dangling link now fails with "can't stat", exit code 1.

This is the same rule as gzip and xz: both follow links with -c, -t and -l, and refuse them when they would write a file. The only difference is gzip -rc, which follows a link to a directory; staying more conservative there is fine.

One non-blocking suggestion on the man page: the new section says links are followed "when no output file is written", but -b writes no file and still skips links. Naming the modes would be more accurate, for example:

### Symbolic Links
A symbolic link named on the command line is followed when the output is
standard output (`-c`, `--stdout`), and with `-t` and `-l`. Otherwise, or when
`-r` is used, symbolic links are skipped with a warning. `-f` overrides this
and follows all symbolic links.

@jlee303

jlee303 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for detailed review and verifying fix! I updated the man page :)

@jlee303
jlee303 merged commit 7d2b066 into dev Nov 30, 2026
118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants