1
Fork 0
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:
Michael Debertol 2021-07-31 19:40:38 +02:00
parent f29239beec
commit 5bf4536bdd
2 changed files with 10 additions and 1 deletions

View file

@ -173,7 +173,7 @@ impl Output {
BufWriter::new(match self.file {
Some((_name, file)) => {
// truncate the file
file.set_len(0).unwrap();
let _ = file.set_len(0);
Box::new(file)
}
None => Box::new(stdout()),

View file

@ -1030,3 +1030,12 @@ fn test_output_is_input() {
cmd.args(&["-m", "-o", "file", "file"]).succeeds();
assert_eq!(at.read("file"), input);
}
#[test]
#[cfg(unix)]
fn test_output_device() {
new_ucmd!()
.args(&["-o", "/dev/null"])
.pipe_in("input")
.succeeds();
}