Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion src/uu/split/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,10 @@ fn split(settings: &Settings) -> UResult<()> {
}
Strategy::Lines(chunk_size) => {
let mut writer = LineChunkWriter::new(chunk_size, settings)?;
copy(&mut reader, &mut writer)
match io::copy(&mut reader, &mut writer) {

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.

you should use if_err (or equivalent)

Ok(_) => Ok(()),
Err(e) => Err(USimpleError::new(1, format!("{e}"))),

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.

use strip_errno to remove "(os error "

}
}
Strategy::Bytes(chunk_size) => {
let mut writer = ByteChunkWriter::new(chunk_size, settings)?;
Expand Down
9 changes: 9 additions & 0 deletions tests/by-util/test_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2068,3 +2068,12 @@ fn test_split_directory_already_exists() {
.no_stdout()
.stderr_is("split: 'xaa': Is a directory\n");
}

#[test]
#[cfg(target_os = "linux")]
fn test_io_error() {
new_ucmd!()
.arg("/proc/self/mem")
.fails_with_code(1)
.stderr_contains("(os error 5)\n");

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.

(os error
is something we are trying to remove
please try on the real error message

}
Loading