rm: report specific error when symlink_metadata fails#11124
Open
anihal wants to merge 3 commits intouutils:mainfrom
Open
rm: report specific error when symlink_metadata fails#11124anihal wants to merge 3 commits intouutils:mainfrom
anihal wants to merge 3 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
Contributor
|
please add a test |
Previously, any error from symlink_metadata was silently swallowed under -f, or always reported as "No such file or directory" regardless of the actual error kind. Fix this by: - Matching NotFound explicitly: silent under -f, "No such file or directory" otherwise (preserving the existing behaviour). - Routing all other errors (e.g. Permission denied on a path component) through show_removal_error so the correct message is always printed, even when -f is given.
Two GNU test regressions from the previous commit: - tests/rm/ignorable: rm -f on a path through a non-directory (ENOTDIR) must exit 0; the catch-all Err arm was ignoring options.force. - tests/rm/inaccessible: without -f, the CI runner expects the message "No such file or directory" (matching current uutils behaviour via CannotRemoveNoSuchFile); switching to show_removal_error changed the wording to "Permission denied" and broke the comparison. Fix: respect options.force in the catch-all Err arm and keep CannotRemoveNoSuchFile for the non-force path, matching pre-PR behaviour. A TODO is left for when the GNU test expectation is updated.
a266bce to
164b1dc
Compare
|
GNU testsuite comparison: |
- test_rm_force_ignores_symlink_metadata_error: verifies that rm -f silently succeeds when a path component is not a directory (ENOTDIR), matching GNU rm behaviour (the ignorable test case). - test_rm_reports_error_for_symlink_metadata_failure: verifies that without -f, the same path causes a non-zero exit with an error referencing the problematic path.
|
GNU testsuite comparison: |
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.
Summary
Previously, any error from
symlink_metadata()in the main file-removalloop was either silently swallowed under
-f, or always reported as"No such file or directory"regardless of the real error kind. TwoTODOcomments called this out explicitly.This PR fixes both issues by splitting the single catch-all
Errarminto two:
NotFound— preserves the existing behaviour: silent under-f,prints
cannot remove 'file': No such file or directoryotherwise.Permission deniedwhen a path componentis not accessible) — always routes through the existing
show_removal_errorhelper so the correct OS-specific message isprinted, even when
-fis passed. This matches GNUrmbehaviour.Before:
After: