Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

head: printing all-but-last-n-lines discrepancy with GNU #7472

Open
karlmcdowall opened this issue Mar 17, 2025 · 0 comments · May be fixed by #7484
Open

head: printing all-but-last-n-lines discrepancy with GNU #7472

karlmcdowall opened this issue Mar 17, 2025 · 0 comments · May be fixed by #7484
Labels

Comments

@karlmcdowall
Copy link
Contributor

karlmcdowall commented Mar 17, 2025

If the last line of a large file doesn't end with a newline then we get a discrepancy between GNU and Rust implementations.
Steps to reproduce...
1 - make a large file without a line ending...
$ seq 70000 | head -c -1 >seq_70000

2 - Compare GNU with Rust
GNU...

$head -n -1 seq_70000
...
69998
69999

Rust

$./target/debug/head -n -1 seq_70000
...
69997
69998

Issue only exists for large files, small files are handled fine.

I'm planning to fix this.

karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Mar 18, 2025
Fixes issue uutils#7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Mar 18, 2025
Fixes issue uutils#7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Mar 18, 2025
Fixes issue uutils#7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Mar 18, 2025
Fixes issue uutils#7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Mar 18, 2025
Fixes issue uutils#7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
@karlmcdowall karlmcdowall linked a pull request Mar 18, 2025 that will close this issue
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Mar 18, 2025
Fixes issue uutils#7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Mar 18, 2025
Fixes issue uutils#7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Mar 19, 2025
Fixes issue uutils#7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants