Skip to content

head, tail: reject invalid count values even when overridden - #16038

Open
Logic769 wants to merge 1 commit into
uutils:mainfrom
Logic769:head-tail-validate-overridden-counts
Open

Logic769 wants to merge 1 commit into
uutils:mainfrom
Logic769:head-tail-validate-overridden-counts

Conversation

@Logic769

Copy link
Copy Markdown

Problem

GNU validates every -c/-n value even when a later one overrides it: head -c1-3 -n1 reports invalid number of bytes: '1-3' and exits 1, while uutils only parsed the surviving value and printed the input. tail --bytes 1,2 --lines 2 had the same problem.

Change

Extract every literal -c/-n value from the raw command line (including overridden ones) in uucore, then validate each one in head and tail. Obsolete numeric syntax is left to the existing parser. Added regression tests for both commands.

Closes #15997

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/tail/tail. tests/tail/tail is passing on 'main'. Maybe you have to rebase?

@Logic769
Logic769 force-pushed the head-tail-validate-overridden-counts branch 2 times, most recently from 937b4e5 to 0b67b2d Compare October 30, 2026 13:32
@Logic769
Logic769 force-pushed the head-tail-validate-overridden-counts branch from 0b67b2d to 6dc0c1b Compare October 30, 2026 22:02
@codspeed

codspeed Bot commented Oct 31, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 7.27%

2 warnings, 2 notes

⚠️ 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 with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ This run is excluded from the branch history

This commit was force-pushed, so this run no longer appears in the branch's performance history.

ℹ️ 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 regressed benchmark
✅ 400 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation sort_long_line[10000] 1 ms 1.1 ms -7.27%

Tip

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


Comparing Logic769:head-tail-validate-overridden-counts (0b67b2d) with main (aea67c0)2

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

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

This branch has not been deployed

No deployments
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.

head: an invalid -c value is ignored when -n comes later

1 participant