Skip to content

pr: an option value that looks like an operand is taken for one, and invalid numbers and page ranges are reported differently from GNU #15179

Open

Description

@NdekoCode

The scan for legacy -COLUMN and +PAGE operands runs on every argument, including the value of an option:

$ printf 'a\nb\n' > f
$ pr -l -1 f
pr: invalid --length argument 'f'
$ pr -l +5 f        # GNU prints f with a page length of 5
pr: invalid --length argument 'f'

GNU 9.12 reads -1 and +5 as the value of -l. The messages for invalid numbers and ranges also differ:

command GNU 9.12 uutils main (a5bc606)
pr --pages=0 f invalid page range '0' invalid --pages argument '0'
pr --pages=2:1 f invalid page range '2:1' invalid --pages argument '2:1'
pr --pages=99999999999999999999 f --pages argument '99999999999999999999' too large invalid --pages argument '99999999999999999999'
pr -l 0 f '-l PAGE_LENGTH' invalid number of lines: '0': Numerical result out of range invalid --length argument '0'
pr -l x f '-l PAGE_LENGTH' invalid number of lines: 'x' invalid --length argument 'x'
pr -w 0 f, -W 0 '-w PAGE_WIDTH' invalid number of characters: '0': Numerical result out of range invalid --width argument '0'
pr -N x f '-N NUMBER' invalid starting line number: 'x' invalid --first-line-number argument 'x'
pr --columns=0 f invalid number of columns: '0': Numerical result out of range invalid --columns argument '0'
pr +x f invalid + argument 'x' pr: +x: No such file or directory
pr +1:3x f invalid suffix in + argument '1:3x' pr: +1:3x: No such file or directory
pr +99999999999999999999 f + argument '99999999999999999999' too large invalid + argument '99999999999999999999'
pr +0 f, pr +2:1 f pr: +0: No such file or directory (taken for a file) nothing printed, exit 0 / invalid --pages argument '2:1'

This is what pr/options.sh in #14705 exercises.

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