pr: make -n/--number-lines argument optional to match GNU - #13900
pr: make -n/--number-lines argument optional to match GNU#13900AlejandroCoronadoN wants to merge 1 commit into
Conversation
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.
a5fa914 to
6a8c3d3
Compare
Merging this PR will regress 1 benchmark
|
| 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
Footnotes
-
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. ↩
-
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. ↩
Problem
GNU
prtreats the-n/--number-linesargument as optional. uutils requireda value, so a bare flag failed:
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
prover-n,--number-lines,-n5,-n:3,-nx3, and-n FILE; all match byte for byte.--number-lines=(explicit empty value) is still rejected. Added a regressiontest; the full
test_prsuite (239 tests) passes andcargo fmt/cargo clippyare clean.