mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
head: display errors for each input file
Change the behavior of `head` to display an error for each problematic file, instead of displaying an error message for the first problematic file and terminating immediately at that point. This change now matches the behavior of GNU `head`. Before this commit, the first error caused the program to terminate immediately: $ head a b c head: error: head: cannot open 'a' for reading: No such file or directory After this commit: $ head a b c head: cannot open 'a' for reading: No such file or directory head: cannot open 'b' for reading: No such file or directory head: cannot open 'c' for reading: No such file or directory
This commit is contained in:
parent
9e2c82d8e7
commit
eeef8290df
3 changed files with 52 additions and 40 deletions
|
@ -162,6 +162,18 @@ fn test_no_such_file_or_directory() {
|
|||
.stderr_contains("cannot open 'no_such_file.toml' for reading: No such file or directory");
|
||||
}
|
||||
|
||||
/// Test that each non-existent files gets its own error message printed.
|
||||
#[test]
|
||||
fn test_multiple_nonexistent_files() {
|
||||
new_ucmd!()
|
||||
.args(&["bogusfile1", "bogusfile2"])
|
||||
.fails()
|
||||
.stdout_does_not_contain("==> bogusfile1 <==")
|
||||
.stderr_contains("cannot open 'bogusfile1' for reading: No such file or directory")
|
||||
.stdout_does_not_contain("==> bogusfile2 <==")
|
||||
.stderr_contains("cannot open 'bogusfile2' for reading: No such file or directory");
|
||||
}
|
||||
|
||||
// there was a bug not caught by previous tests
|
||||
// where for negative n > 3, the total amount of lines
|
||||
// was correct, but it would eat from the second line
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue