mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
tac: Flush BufWriter
This commit is contained in:
parent
d456e90596
commit
11ef1522ca
2 changed files with 12 additions and 0 deletions
|
@ -164,6 +164,7 @@ fn buffer_tac_regex(
|
|||
// After the loop terminates, write whatever bytes are remaining at
|
||||
// the beginning of the buffer.
|
||||
out.write_all(&data[0..following_line_start])?;
|
||||
out.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -215,6 +216,7 @@ fn buffer_tac(data: &[u8], before: bool, separator: &str) -> std::io::Result<()>
|
|||
// After the loop terminates, write whatever bytes are remaining at
|
||||
// the beginning of the buffer.
|
||||
out.write_all(&data[0..following_line_start])?;
|
||||
out.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -309,3 +309,13 @@ fn test_regex_before() {
|
|||
// |--------||----||---|
|
||||
.stdout_is("+---+c+d-e+--++b+-+a+");
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_failed_write_is_reported() {
|
||||
new_ucmd!()
|
||||
.pipe_in("hello")
|
||||
.set_stdout(std::fs::File::create("/dev/full").unwrap())
|
||||
.fails()
|
||||
.stderr_is("tac: failed to write to stdout: No space left on device (os error 28)\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue