Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix negative args and files without ending \n #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

E5ten
Copy link

@E5ten E5ten commented Oct 2, 2019

To support negative arguments to -n like some other head implementations, mapfile the whole file to get the total length and if the arg is negative, make the lines printed the arg added to the file length.
Don't remove trailing newlines with mapfile, and don't add them with printf, to avoid printing an extra newline when a file doesn't end with one.

If arg is negative, make the max lines it subtracted from the file length, like other head implementations
Don't remove trailing newlines with mapfile, and don't add them with printf, to avoid printing an extra newline when a file doesn't end with one.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant