Skip to content

nl: accept negative values for -v and -i - #16018

Merged
sylvestre merged 3 commits into
uutils:mainfrom
Logic769:nl-allow-negative-values
Nov 2, 2026
Merged

sylvestre merged 3 commits into
uutils:mainfrom
Logic769:nl-allow-negative-values

Conversation

@Logic769

Copy link
Copy Markdown
Contributor

Problem

nl -v -1 and nl -i -1 are rejected by the argument parser because negative values are treated as options, whereas GNU nl accepts them.

Change

Set .allow_negative_numbers(true) on -v/--starting-line-number and -i/--line-increment so negative integers are accepted.

Tests

Added test_negative_starting_line_and_increment in tests/by-util/test_nl.rs, verifying output when starting at -1 with increment 1.

Closes #15999

Comment thread tests/by-util/test_nl.rs Resolved
@Logic769
Logic769 force-pushed the nl-allow-negative-values branch from 54e330d to e75d4f8 Compare October 30, 2026 13:03
@Logic769

Copy link
Copy Markdown
Contributor Author

Added a test for a negative increment given as a separate argument: both -i -1 and --line-increment -1 print the -1 column.

Comment thread tests/by-util/test_nl.rs Resolved
@codspeed

codspeed Bot commented Nov 2, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 20.6%

1 warning, 1 note

⚠️ 120 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
✅ 400 untouched benchmarks
⏩ 70 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation mv_force_overwrite 154.4 ms 128 ms +20.6%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Logic769:nl-allow-negative-values (4c480a9) with main (9cc868b)

Open in CodSpeed

Footnotes

  1. 70 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. ↩

@sylvestre
sylvestre merged commit c88e7d5 into uutils:main Nov 2, 2026
230 of 231 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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.

nl: negative values for -v / -i are rejected

2 participants