Skip to content

head: allow '+' prefix on line count#1044

Merged
briandfoy merged 1 commit into
briandfoy:masterfrom
mknos:head-nplus
Jun 12, 2026
Merged

head: allow '+' prefix on line count#1044
briandfoy merged 1 commit into
briandfoy:masterfrom
mknos:head-nplus

Conversation

@mknos

@mknos mknos commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
  • The standards document says head -n COUNT counts from one [1]
  • The OpenBSD and GNU versions accept a '+' prefix on a number, so allow that here for compat

Tests:
perl head -2 head --> 2 lines
perl head -n2 head --> 2 lines
perl head -n+2 head --> 2 lines
perl head -n-2 head --> invalid

  1. https://pubs.opengroup.org/onlinepubs/9799919799/utilities/head.html

* The standards document says -n COUNT counts from one [1]
* The OpenBSD and GNU versions accept a '+' prefix on a number, so allow that here for compat

Tests:
perl head -2 head --> 2 lines
perl head -n2 head --> 2 lines
perl head -n+2 head --> 2 lines
perl head -n-2 head --> invalid

1. https://pubs.opengroup.org/onlinepubs/9799919799/utilities/head.html
@mknos mknos temporarily deployed to housekeeping June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing June 11, 2026 07:48 — with GitHub Actions Inactive
@github-actions github-actions Bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: head The head program Status: needs verification issue needs to be verified Type: bug an existing feature does not work labels Jun 11, 2026
@briandfoy briandfoy removed the Status: needs verification issue needs to be verified label Jun 11, 2026
Comment thread bin/head
@briandfoy briandfoy merged commit 4e61810 into briandfoy:master Jun 12, 2026
23 of 24 checks passed
@briandfoy briandfoy deployed to housekeeping June 12, 2026 02:39 — with GitHub Actions Active
@github-actions github-actions Bot added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Jun 12, 2026
@briandfoy briandfoy added Priority: low get to this whenever and removed Type: bug an existing feature does not work Status: accepted The fix is accepted labels Jun 12, 2026
@briandfoy

Copy link
Copy Markdown
Owner

changes: count from 1 and accept +N syntax

@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Program: head The head program Status: accepted The fix is accepted Type: enhancement improve a feature that already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants