pr: --first-line-number counts lines on skipped pages

Open Beginner friendly
#16,660 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
83/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli

Research direction

Start in src/uu/pr/src/pr.rs: the issue points to the option parser at lines 796–802 and pagination loop at lines 1268–1285. Compare how omitted -N and explicit -N1 are represented, then trace when the line number advances relative to the printed page. Add regression coverage for the shown -N cases; done when the output matches the GNU results in the table.

Written by the indexing model from the issue text.

Description

With one line per page, +2 skips the first line. The help for -N says numbering starts at the first line of the first page printed, so the line containing b should be numbered 8.

printf 'a\nb\n' | LC_ALL=C pr -t -l1 +2 -n:1 -N8

On Linux, uutils 108f21e prints 9:b. GNU coreutils 9.12 prints 8:b. Both exit 0.

There is also a distinction worth covering in a regression test:

Last argument GNU 9.12 uutils 108f21e
Omit -N 2:b 2:b
-N1 1:b 2:b
-N8 8:b 9:b

The option parser stores the same starting number for an omitted -N and an explicit -N1. The pagination loop increments the line number before checking whether the page will be printed.

Dominant language
Rust
Stars
24.4k
Forks
2.2k
Avg merge
3d 6h
Merged PRs (30d)
434

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uutils/coreutils

All issues in uutils/coreutils

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.