1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tail: support zero-terminated lines in streams

Support `-z` option when the input is not a seekable file. Previously,
the option was accepted by the argument parser, but it was being
ignored by the application logic.
This commit is contained in:
Jeffrey Finkelstein 2022-01-20 19:15:18 -05:00
parent 8c298e97a5
commit 58d84d5107
3 changed files with 66 additions and 21 deletions

View file

@ -489,3 +489,17 @@ fn test_no_such_file() {
fn test_no_trailing_newline() {
new_ucmd!().pipe_in("x").succeeds().stdout_only("x");
}
#[test]
fn test_lines_zero_terminated() {
new_ucmd!()
.args(&["-z", "-n", "2"])
.pipe_in("a\0b\0c\0d\0e\0")
.succeeds()
.stdout_only("d\0e\0");
new_ucmd!()
.args(&["-z", "-n", "+2"])
.pipe_in("a\0b\0c\0d\0e\0")
.succeeds()
.stdout_only("b\0c\0d\0e\0");
}