coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

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

Open karlmcdowall opened this issue 10 months ago • 0 comments

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 avatar Mar 17 '25 16:03 karlmcdowall