Skip to content

pr: accept a plus sign and leading blanks in page numbers - #16634

Merged
cakebaker merged 2 commits into
uutils:mainfrom
binhvq:pr-pages-plus-sign
Nov 20, 2026
Merged

cakebaker merged 2 commits into
uutils:mainfrom
binhvq:pr-pages-plus-sign

Conversation

@binhvq

@binhvq binhvq commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Closes #16633

pr --pages=+2, pr --pages='2: 3' and pr +2:+3 failed with invalid --pages argument. Each page number may now have blanks and one + before its digits, so these select the same pages as 2, 2:3 and +2:3.

Comment thread src/uu/pr/src/pr.rs Outdated
use PageSpecError::{InvalidSuffix, NotANumber, NotARange, TooLarge};
fn number(part: &str) -> Result<(usize, &str), PageSpecError> {
// Blanks and one `+` may come before the digits.
let part = part.trim_start_matches(|c: char| c.is_ascii_whitespace());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_ascii_whitespace doesn't include \v, does GNU accept --pages=$'\v2'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, GNU pr 9.12 takes --pages=$'\v2' (also \f, \r and \n), so I missed that one. It now skips the same set as fold -w and the test has a \v case.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.49 MB (+108 KB, +0.07%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

@cakebaker
cakebaker merged commit a741688 into uutils:main Nov 20, 2026
104 of 106 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pr: page numbers with a leading + or leading blanks are rejected

3 participants