Repository navigation
chmod: report every failure met under -R - #15166
Merged
Merged
Conversation
sylvestre
reviewed
Oct 8, 2026
sylvestre
reviewed
Oct 8, 2026
Failures met while walking a tree were returned up through `Result::and`, so only one of them reached stderr, after all the other output, and `-f` could not hide it. An unreadable directory was also reported as "cannot access", where GNU says "cannot read directory", and on Hurd the `read_dir` error came back without its path. Report each failure where it happens and keep the exit status, let `-f` hide the messages, report an unreadable directory as "cannot read directory", and with `-v` add the "could not be accessed" line that GNU prints for it.
The mode was parsed again for every file, so under -R a bad one was reported once per entry, after the walk had started. Whether it parses does not depend on the file: check it up front, as GNU does.
change_file printed its own error and returned a bare exit code, which the recursive walk told apart from a real error by its empty message. Return the error instead and let one helper print it, unless -f, and set the exit status, for the operand loop as well as for the walk: every failing operand is reported, as GNU does. The umask diagnostic is shown where it is found, since GNU prints it even under -f.
'/' is read-only on macOS, so the message ends differently there.
NdekoCode
force-pushed
the
chmod-report-every-error
branch
from
October 20, 2026 19:34
24f5cc3 to
1c488d5
Compare
Contributor
Author
|
@sylvestre rebased on main. The new test no longer checks the errno text, '/' is read-only on macOS. |
Contributor
|
Thanks for your PR |
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.
chmod -Rreturned the failures met while walking a tree up throughResult::and, so only one of them reached stderr, after all the other output, and-fcould not hide it. An unreadable directory was also reported ascannot access, where GNU sayscannot read directory, and on Hurd theread_direrror came back without its path.The walk now reports each failure where it happens and keeps the exit status,
-fhides the messages, an unreadable directory is reported ascannot read directory 'd/a': Permission denied, and-vadds the'd/a' could not be accessedline GNU prints for it. Checked against GNU 9.12.Closes #15153. Covers the chmod half of #15154.