Skip to content

fix(tail): handle zero line counts - #1271

Open
jakezwang wants to merge 1 commit into
shelljs:mainfrom
jakezwang:fix-tail-zero-lines
Open

jakezwang wants to merge 1 commit into
shelljs:mainfrom
jakezwang:fix-tail-zero-lines

Conversation

@jakezwang

Copy link
Copy Markdown

tail({ '-n': 0 }, file) currently returns the whole file, while tail('-n', 0, file) reports no paths. Handle a zero count after validating the file arguments, preserving file errors. Also make +0 start at the first line, consistent with native tail.

Add regressions for both option forms, multiple files, piped input, and missing files.

Validation: npm test passes on Node 20, 24, and 26 (631 passed, 6 existing skips). Coverage, lint, and the Node support check pass. An additional 36 cases match native tail output.

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.

1 participant