Repository navigation
readlink: ensure last of -e / -f / -m takes precedence - #16401
Open
abdul-karim-mia wants to merge 1 commit into
Open
abdul-karim-mia wants to merge 1 commit into
abdul-karim-mia wants to merge 1 commit into
Conversation
aozmekik
approved these changes
Nov 13, 2026
aozmekik
left a comment
There was a problem hiding this comment.
Checked this against GNU coreutils 9.12 (Debian sid): every order of -e/-f/-m (pairs, triples, bundled ones like -ef and -mfe, and the long names) on an existing file, a good and a dangling symlink, missing, missing/nested, dir/missing and a symlink loop, for both readlink and realpath. Of the 238 cases, main differs from GNU in 50 and this branch in 10, and all 10 are -m on the symlink loop, which is #16325. It also fixes -m -f missing/nested, which main accepted.
|
GNU testsuite comparison: |
abdul-karim-mia
force-pushed
the
fix/readlink-canonicalize-precedence
branch
from
November 17, 2026 13:24
aeb3370 to
59f4390
Compare
|
Binary size comparison: |
sylvestre
force-pushed
the
fix/readlink-canonicalize-precedence
branch
from
November 18, 2026 09:25
59f4390 to
974e940
Compare
abdul-karim-mia
force-pushed
the
fix/readlink-canonicalize-precedence
branch
from
November 19, 2026 09:25
974e940 to
93e943c
Compare
…15995) Add overrides_with_all across OPT_CANONICALIZE, OPT_CANONICALIZE_EXISTING, and OPT_CANONICALIZE_MISSING so that whichever flag is specified last takes precedence, matching GNU coreutils behavior. Add integration tests verifying precedence across all canonicalize flag permutations. Signed-off-by: Abdul karim mia <[email protected]>
abdul-karim-mia
force-pushed
the
fix/readlink-canonicalize-precedence
branch
from
November 19, 2026 13:55
93e943c to
f61f2af
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #15995
In GNU
readlink, specifying multiple canonicalize options (-f/--canonicalize,-e/--canonicalize-existing, and-m/--canonicalize-missing) follows last-flag-wins semantics. For example:In GNU coreutils,
--canonicalize(-f) came last, so it resolves the missing path (exiting 0). Inuutils/coreutils, the argument definitions for the three canonicalize options did not declare mutual overrides, andcan_modeevaluated-ebefore-mand-f, causing-eto always win regardless of option order.Solution
.overrides_with_all([OPT_CANONICALIZE, OPT_CANONICALIZE_EXISTING, OPT_CANONICALIZE_MISSING])to each ofOPT_CANONICALIZE,OPT_CANONICALIZE_EXISTING, andOPT_CANONICALIZE_MISSINGinuu_app(), mirroring the existing overrides pattern used for[OPT_QUIET, OPT_SILENT, OPT_VERBOSE].tests/by-util/test_readlink.rs(test_canonicalize_precedence) covering all order permutations between-e,-f, and-m.Verification
cargo test --features readlink --test tests test_canonicalize_precedence: Passed (1/1)cargo fmt --check: Passed (no diff)cargo clippy -p uu_readlink: Passed (0 warnings)