Bug
head does not support the shorthand form head -5 (passing a number directly without -n), while tail handles it correctly.
Expected behavior (bash-compatible):
$ echo -e "1\n2\n3\n4\n5\n6" | head -5
1
2
3
4
5
Actual behavior:
head -5 likely returns an "unknown flag" or similar error.
Source
Reported internally via Slack (2026-04-02).
Fix
When parsing flags in the head builtin, handle the case where a bare numeric argument (e.g. -5, -42) is passed — treating it as equivalent to -n 5 / -n 42. This matches POSIX/bash/GNU behaviour.
tail already implements this correctly and can serve as a reference.
Bug
headdoes not support the shorthand formhead -5(passing a number directly without-n), whiletailhandles it correctly.Expected behavior (bash-compatible):
Actual behavior:
head -5likely returns an "unknown flag" or similar error.Source
Reported internally via Slack (2026-04-02).
Fix
When parsing flags in the
headbuiltin, handle the case where a bare numeric argument (e.g.-5,-42) is passed — treating it as equivalent to-n 5/-n 42. This matches POSIX/bash/GNU behaviour.tailalready implements this correctly and can serve as a reference.