Repository navigation
find: report -print write errors on standard output - #908
Conversation
`-print`, `-print0`, and the implicit print returned 1 without a diagnostic when a write to standard output failed. Route them through the same handler as `-ls` and `-printf`, which reports the first error once for the command. A broken pipe now stops the walk and preserves an earlier exit status instead of returning 0. `-fprint` and `-fprint0` are unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #908 +/- ##
=======================================
Coverage 92.54% 92.54%
=======================================
Files 36 37 +1
Lines 7727 7754 +27
Branches 393 393
=======================================
+ Hits 7151 7176 +25
- Misses 436 437 +1
- Partials 140 141 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance
|
| ) | ||
| .and_then(|()| out.flush()); | ||
| if let Err(e) = result { | ||
| if !print_error_message { |
There was a problem hiding this comment.
print_error_message now means "writing to stdout", maybe rename it or check self.output_file.is_none()?
There was a problem hiding this comment.
Done. The flag only had that one use I removed it and now check self.output_file.is_none() directly.
| &["-printf", "%p\n"], | ||
| &["-ls", "-printf", "%p\n"], | ||
| &["-print", "-ls"], | ||
| &["-print0", "-ls"], |
There was a problem hiding this comment.
could you please add -print to find_stops_when_stdout_pipe_is_closed too? the broken pipe path changed as well
There was a problem hiding this comment.
Added. This case also passes on main because -print exits 0 on EPIPE before -fprint gets to write anything. It still guards the behavior changed
The `print_error_message` argument was only used to tell whether `Printer::print` was writing to stdout. Check `self.output_file.is_none()` instead and remove the argument. Also add `-print` to the closed-pipe test.
|
Thanks for your PR |
Follow-up to #905:
-print,-print0, and the implicit print now use the same stdout error handler as-lsand-printf.Before this change, the command returned 1 with no diagnostic. It now reports the error:
The first write error is now reported once for the whole command, including when these actions are mixed with
-lsor-printf. A broken pipe stops the walk and preserves any earlier nonzero status instead of returning 0.-fprintand-fprint0are unchanged.