diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index 511cfac7e..4496c2ce1 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -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(()) } diff --git a/tests/by-util/test_tac.rs b/tests/by-util/test_tac.rs index f725615b3..42e7b76d6 100644 --- a/tests/by-util/test_tac.rs +++ b/tests/by-util/test_tac.rs @@ -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"); +}