Skip to content

pr: -n repeats line numbers after a form feed #16131

Closed

Description

@limadog9

pr -n does not advance the line counter when a form feed ends a line. The next line receives the same number, and later line numbers are too small.

Reproduced on Linux x86_64 (Debian 13), using uutils 0.13.0 from main at 43eb6205c20c551480057cdee98e6e7529cd984d, with LC_ALL=C LANG=C. GNU coreutils 9.12 (the reference package linked in CONTRIBUTING.md) and 9.7 both produce the expected result.

From the repository root:

cargo build --locked -p uu_pr
export LC_ALL=C LANG=C
printf 'a\fb\nc\n' | target/debug/pr -T -n:1

Actual output:

1:a
1:b
2:c

Expected output (GNU 9.12 and 9.7):

1:a
2:b
3:c

Both exit 0 with empty stderr. -T removes pagination, making the numbering difference visible without headers or page separators.

The problem also occurs without a trailing newline and with -N10. With a\fb\fc\n, all three lines receive number 1. As controls, a\nb\nc\n and a\n\fb\nc\n produce 1, 2, 3 in both implementations.

In get_pages, pr.rs:1153–1156, the form-feed branch pushes a FileLine without incrementing line_num. The newline branch increments it at line 1183.

No matching report was found in searches of open and closed issues and related PRs for pr numbering and form feeds. Existing #12313 and #14334 describe column formatting and page padding, rather than repeated line numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions