fix(chown,chgrp): print --verbose success lines to stdout - #13419
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
|
GNU testsuite comparison: |
There was a problem hiding this comment.
I would use writeln! instead of println!, otherwise the example from #13408 will panic:
$ cargo run --features=unix -q chgrp --verbose "$(id -gn)" "$tmp/f" > /dev/full ; echo "exit=$?"
chgrp: cannot dereference '/f': No such file or directory
thread 'main' (79884) panicked at /rustc/2d8144b7880597b6e6d3dfd63a9a9efae3f533d3/library/std/src/io/stdio.rs:1166:9:
failed printing to stdout: No space left on device (os error 28)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
exit=101
There was a problem hiding this comment.
Thanks — switched the verbose success path to writeln! so a full/closed stdout reports a write error instead of panicking on println!.
Pushed as a small helper in perms.rs; focused cargo check / clippy on uu_chown + uu_chgrp are green.
Main already writes some verbose lines with writeln! and reports /dev/full write errors, but successful retained/changed messages from wrap_chown and report_ownership_change_success still went through show_error! (stderr + util-name prefix). Route those informational lines through write_verbose_line so GNU-style stdout output is preserved and write failures still surface on flush. Update chown/chgrp tests accordingly. Fixes uutils#13408 Signed-off-by: Alex Chen <l46983284@gmail.com>
47fd467 to
66bf90a
Compare
|
Rebased onto current
Local: |
Returning early after write_verbose_line skipped -R children and left recursive/symlink-cycle suites looking for retained lines that were never printed. Write the line and continue into safe_dive/dive. Also drop accidental backslash-escaped quotes in the recursive test needles so they match path.quote() output. Signed-off-by: Alex Chen <l46983284@gmail.com>
|
Pushed a small residual fix for the recursive path. After routing verbose retained lines to stdout, the root traverse was returning early and never visited children under Local: |
|
Thanks for your PR! |
Summary
chown/chgrp --verbosewas printing successfulchanged/retainedlines to stderr with achown:/chgrp:prefix becausereport_ownership_change_successand thewrap_chownOk path usedshow_error!.GNU prints those informational lines to stdout with no util-name prefix. This PR routes success-path verbose/changes output through
println!and leaves real errors on stderr.Changes
src/uucore/src/lib/features/perms.rs: success verbose/changes → stdouttests/by-util/test_chown.rs,tests/by-util/test_chgrp.rs: assert retained/changed lines on stdoutTest plan
test_chown/test_chgrpchgrp --verbose "$(id -gn)" file >out 2>err→ line inout, emptyerr, nochgrp:prefixFixes #13408