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

head: don't add trailing newline to end of file

Prevent `head` from adding a trailing newline to the end of a file
that did not originally have one when using `head --lines=-0`.
This commit is contained in:
Jeffrey Finkelstein 2022-01-29 22:15:23 -05:00
parent 7b3cfcf708
commit cba0696b90
3 changed files with 88 additions and 5 deletions

View file

@ -157,11 +157,17 @@ fn test_negative_byte_syntax() {
#[test]
fn test_negative_zero_lines() {
new_ucmd!()
.args(&["--lines=-0"])
.arg("--lines=-0")
.pipe_in("a\nb\n")
.succeeds()
.stdout_is("a\nb\n");
new_ucmd!()
.arg("--lines=-0")
.pipe_in("a\nb")
.succeeds()
.stdout_is("a\nb");
}
#[test]
fn test_negative_zero_bytes() {
new_ucmd!()