Skip to content

chmod: report every failure met under -R - #15166

Merged
sylvestre merged 4 commits into
uutils:mainfrom
NdekoCode:chmod-report-every-error
Oct 24, 2026
Merged

sylvestre merged 4 commits into
uutils:mainfrom
NdekoCode:chmod-report-every-error

Conversation

@NdekoCode

Copy link
Copy Markdown
Contributor

chmod -R returned the failures met while walking a tree 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.

The walk now reports each failure where it happens and keeps the exit status, -f hides the messages, an unreadable directory is reported as cannot read directory 'd/a': Permission denied, and -v adds the 'd/a' could not be accessed line GNU prints for it. Checked against GNU 9.12.

Closes #15153. Covers the chmod half of #15154.

Comment thread src/uu/chmod/src/chmod.rs Outdated
Comment thread src/uu/chmod/src/chmod.rs Outdated
@NdekoCode
NdekoCode requested a review from sylvestre October 9, 2026 21:54
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
NdekoCode force-pushed the chmod-report-every-error branch from 24f5cc3 to 1c488d5 Compare October 20, 2026 19:34
@NdekoCode

NdekoCode commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@sylvestre rebased on main. The new test no longer checks the errno text, '/' is read-only on macOS.

@sylvestre
sylvestre merged commit 64daabd into uutils:main Oct 24, 2026
99 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chmod: -R reports only one of several errors

2 participants