Skip to content

head: honor the current stdin offset for -n -N and -c -N - #16043

Open
Logic769 wants to merge 1 commit into
uutils:mainfrom
Logic769:head-stdin-offset-backwards
Open

Logic769 wants to merge 1 commit into
uutils:mainfrom
Logic769:head-stdin-offset-backwards

Conversation

@Logic769

Copy link
Copy Markdown
Contributor

When stdin is a seekable regular file that has already been partly read and is
larger than st_blksize, head -n -N and head -c -N treated stdin as
starting at byte 0. head -n -N re-printed the consumed leading bytes and
head -c -N printed part of the tail it should have dropped, and stdin was left
at the wrong offset.

head_backwards_on_seekable_file now computes its counts from the current file
offset instead of absolute offsets, and find_nth_line_from_end searches only
the data after the current position. A partly consumed seekable stdin is
therefore handled like GNU head, while file operands and pipes are unchanged.

Tests cover both -n -N and -c -N on a large file whose first line has
already been consumed.

Closes #15756

@sylvestre

Copy link
Copy Markdown
Contributor

@Logic769 as I asked you many time to stop pushing a lot of patches and you ignored me, i have no other solutions than to block you temporarily.

@Logic769
Logic769 force-pushed the head-stdin-offset-backwards branch from 3b90f78 to 2be886f Compare October 30, 2026 13:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

head: -n -N and -c -N ignore stdin offset when stdin exceeds blksize

2 participants