Repository navigation
Fix broken pipe error, issue #192 - #195
GunterSchmidt wants to merge 4 commits into
Conversation
|
This fix will return while GNU diff does suppresses it completely. This could easily be changed, but I prefer to output this error message. Reason: Using diff on different files should return exit code 1, but returns in this case 0 without an error message. This is completely wrong information to the user. This version sets exit code 1, which seems correct, since |: would not produce an error if no output was written as in the equal case. |
* fixes issue uutils#165 * simpler format of io errors (remove (os error 2))
|
could you please fix the conflicts? thanks |
| regex = "1.10.4" | ||
| same-file = "1.0.6" | ||
| unicode-width = "0.2.0" | ||
| uucore = "0.6.0" |
There was a problem hiding this comment.
pulling the whole uucore (fluent, unic-langid, …) just for one error message seems too much
please do it with std, format_io_error is already there
| ); | ||
| } | ||
| println!(); | ||
| // Instead of println!(), which panics in case of error (> /dev/full). |
There was a problem hiding this comment.
the print! just above will panic the same way on /dev/full
| let mut stdout = io::stdout(); | ||
| if let Err(e) = writeln!(stdout) { | ||
| return Err(format_io_error(&e)); | ||
| }; |
There was a problem hiding this comment.
could use ? with map_err instead of the if let + stray ;
| @@ -91,7 +92,26 @@ pub fn main(opts: Peekable<ArgsOs>) -> ExitCode { | |||
| params.to.to_string_lossy() | |||
There was a problem hiding this comment.
this println! still panics with --brief | :, no?
| ); | ||
| } else { | ||
| io::stdout().write_all(&result).unwrap(); | ||
| let result = io::stdout().write_all(&result); |
There was a problem hiding this comment.
please add tests in tests/integration.rs for both /dev/full and a closed pipe, for diff and cmp
| uucore::show_error!("{err}"); | ||
| #[cfg(unix)] | ||
| if uucore::signals::sigpipe_was_ignored() { | ||
| uucore::error::set_exit_code(1); |
There was a problem hiding this comment.
is this doing anything? diff returns its own ExitCode, uucore's exit code is never read
| ) | ||
| } | ||
|
|
||
| pub fn format_io_error(error: &dyn std::error::Error) -> String { |
There was a problem hiding this comment.
removing the regex is fine but unrelated, could you please split it out?
Fixes #192 with code used in coreutils.