mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
sort: ignore failure to truncate the output file
This commit is contained in:
parent
f29239beec
commit
5bf4536bdd
2 changed files with 10 additions and 1 deletions
|
@ -173,7 +173,7 @@ impl Output {
|
||||||
BufWriter::new(match self.file {
|
BufWriter::new(match self.file {
|
||||||
Some((_name, file)) => {
|
Some((_name, file)) => {
|
||||||
// truncate the file
|
// truncate the file
|
||||||
file.set_len(0).unwrap();
|
let _ = file.set_len(0);
|
||||||
Box::new(file)
|
Box::new(file)
|
||||||
}
|
}
|
||||||
None => Box::new(stdout()),
|
None => Box::new(stdout()),
|
||||||
|
|
|
@ -1030,3 +1030,12 @@ fn test_output_is_input() {
|
||||||
cmd.args(&["-m", "-o", "file", "file"]).succeeds();
|
cmd.args(&["-m", "-o", "file", "file"]).succeeds();
|
||||||
assert_eq!(at.read("file"), input);
|
assert_eq!(at.read("file"), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn test_output_device() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-o", "/dev/null"])
|
||||||
|
.pipe_in("input")
|
||||||
|
.succeeds();
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue