mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
Merge pull request #1609 from kevinburkemeter/sort-panic
sort: fix panic on write to closed pipe
This commit is contained in:
commit
ce66f3fbdb
2 changed files with 14 additions and 4 deletions
|
@ -550,10 +550,7 @@ where
|
||||||
|
|
||||||
for line in iter {
|
for line in iter {
|
||||||
let str = format!("{}\n", line);
|
let str = format!("{}\n", line);
|
||||||
if let Err(e) = file.write_all(str.as_bytes()) {
|
crash_if_err!(1, file.write_all(str.as_bytes()))
|
||||||
show_error!("sort: {0}", e.to_string());
|
|
||||||
panic!("Write failed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,19 @@ fn test_merge_reversed() {
|
||||||
.stdout_only_fixture("merge_ints_reversed.expected");
|
.stdout_only_fixture("merge_ints_reversed.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pipe() {
|
||||||
|
// TODO: issue 1608 reports a panic when we attempt to read from stdin,
|
||||||
|
// which was closed by the other side of the pipe. This test does not
|
||||||
|
// protect against regressions in that case; we should add one at some
|
||||||
|
// point.
|
||||||
|
new_ucmd!()
|
||||||
|
.pipe_in("one\ntwo\nfour")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("four\none\ntwo\n")
|
||||||
|
.stderr_is("");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_check() {
|
fn test_check() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue