Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/uu/tee/src/tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,19 @@ impl MultiWriter {

fn write_flush(&mut self, buf: &[u8]) -> Result<()> {
let mut aborted = None;
let mut errors = 0;
let mode = self.output_error_mode;
self.writers.retain_mut(|writer| {
let res = (|| {
writer.inner.write_all(buf)?;
writer.inner.flush()
})();
match res {
Ok(()) => true,
Err(e) => {
if let Err(e) = process_error(mode, e, writer, &mut errors) {
aborted.get_or_insert(e);
}
false
res.map_err(|e| {
if let Err(e) = process_error(mode, e, writer, &mut self.ignored_errors) {
aborted.get_or_insert(e);
}
}
})
.is_ok()
Comment on lines +204 to +209
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
res.map_err(|e| {
if let Err(e) = process_error(mode, e, writer, &mut self.ignored_errors) {
aborted.get_or_insert(e);
}
}
})
.is_ok()
if let Err(e) = res {
if let Err(e) = process_error(mode, e, writer, &mut self.ignored_errors) {
aborted.get_or_insert(e);
}
false
} else {
true
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It manually returns true and false instead of reusing bool.

});
self.ignored_errors += errors;
aborted.map_or(
if self.writers.is_empty() {
// This error kind will never be raised by the standard
Expand Down
Loading