Skip to content

head, tail: an invalid count with a leading zero is reported without the leading zeros #14229

Closed

Description

@kennywillbe

head and tail strip leading zeros from the count argument before parsing it, and the resulting error names the stripped string rather than the argument as typed.

$ tail -c0fb a
tail: invalid number of bytes: 'fb'
$ tail -c007z a
tail: invalid number of bytes: '7z'

GNU names the argument as given:

$ tail -c0fb a
tail: invalid number of bytes: '0fb'
$ tail -c007z a
tail: invalid number of bytes: '007z'

head behaves the same way. The stripping happens in parse_signed_num_max (src/uucore/src/lib/features/parser/parse_signed_num.rs), where trimmed is passed to the size parser and so ends up in the error, while the caller formats whatever string the error carries.

Noticed while working on #13136; it is independent of that issue, which is about which suffixes are accepted.

Activity

  1. added a commit that references this issue on Aug 30, 2026
    a43e94f
  2. added a commit that references this issue on Sep 28, 2026
    2014fc9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions