Skip to content

pr: make -n/--number-lines argument optional to match GNU - #13900

Open
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-pr-number-lines-optional
Open

pr: make -n/--number-lines argument optional to match GNU#13900
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-pr-number-lines-optional

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown

Problem

GNU pr treats the -n/--number-lines argument as optional. uutils required
a value, so a bare flag failed:

$ printf 'a\nb\n' | pr -t -n
error: a value is required for '--number-lines <[char][width]>' but none was supplied

Fix

Add num_args(0..=1) to the argument. When no value is given, the existing
.or_else(NumberingMode::default()) fallback already supplies the default
(width 5, tab separator), so no further change is needed.

Verification

Compared against GNU coreutils pr over -n, --number-lines, -n5, -n:3,
-nx3, and -n FILE; all match byte for byte.

$ printf 'a\nb\n' | pr -t -n
    1	a
    2	b

--number-lines= (explicit empty value) is still rejected. Added a regression
test; the full test_pr suite (239 tests) passes and cargo fmt / cargo clippy are clean.

GNU pr treats the -n/--number-lines argument as optional: a bare -n numbers
the lines with a 5-wide, tab-separated line number. uutils required a value,
so `pr -t -n` and `pr -t --number-lines` failed with "a value is required".
Set num_args(0..=1) so the value is optional; the existing fallback already
supplies the default numbering mode.
@sylvestre
sylvestre force-pushed the fix-pr-number-lines-optional branch from a5fa914 to 6a8c3d3 Compare August 13, 2026 07:16
@codspeed-hq

codspeed-hq Bot commented Aug 13, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 345 untouched benchmarks
🆕 10 new benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation numfmt_large_numbers_si[10000] 94.7 ms 98.1 ms -3.4%
Simulation complex_relative_date 330.2 µs 318.6 µs +3.65%
🆕 Memory ptx_input_references_short_lines[100000] N/A 222.2 MB N/A
🆕 Memory ptx_long_lines[100] N/A 29.5 MB N/A
🆕 Memory ptx_short_lines[100000] N/A 240.1 MB N/A
🆕 Memory ptx_input_references_long_lines[1000] N/A 29.1 MB N/A
🆕 Memory ptx_tex[10000] N/A 20.6 MB N/A
🆕 Simulation ptx_input_references_short_lines[100000] N/A 16.1 s N/A
🆕 Simulation ptx_long_lines[100] N/A 1.7 s N/A
🆕 Simulation ptx_short_lines[100000] N/A 14 s N/A
🆕 Simulation ptx_input_references_long_lines[1000] N/A 2 s N/A
🆕 Simulation ptx_tex[10000] N/A 2.9 s N/A

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing AlejandroCoronadoN:fix-pr-number-lines-optional (6a8c3d3) with main (66cf72b)2

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (584dc43) during the generation of this report, so 66cf72b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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.

1 participant