Skip to content

cut: match GNU diagnostics for invalid ranges and options - #13925

Merged
cakebaker merged 1 commit into
mainfrom
cut-diag
Aug 15, 2026
Merged

cut: match GNU diagnostics for invalid ranges and options#13925
cakebaker merged 1 commit into
mainfrom
cut-diag

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

Produce GNU's mode-aware messages (fields vs byte/character positions),
distinguish empty/invalid/decreasing/no-endpoint ranges, and align the
usage errors, all with the 'Try --help' hint.

Should make test tests/cut/cut.pl pass


Stack created with GitHub Stacks CLIGive Feedback 💬

Copilot AI lite review requested due to automatic review settings August 13, 2026 20:08

Copilot AI left a comment

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.

Pull request overview

This PR updates cut’s argument/range parsing diagnostics to better match GNU cut, including mode-aware messages (fields vs byte/character positions) and “usage”-style failures that include the “Try --help” hint.

Changes:

  • Add a GNU-aligned range-list parser in cut to produce more specific diagnostics (empty/invalid/decreasing/no-endpoint/too-large).
  • Switch several error paths from USimpleError to UUsageError so they’re treated as usage errors (with the help hint).
  • Update cut’s locale strings and expand tests to assert the new diagnostic wording.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/by-util/test_cut.rs Adjusts existing assertions and adds a new test matrix for GNU-like range/option diagnostics.
src/uucore/src/lib/features/ranges.rs Exposes Range::merge publicly so cut can merge parsed ranges after custom parsing.
src/uu/cut/src/cut.rs Implements mode-aware range parsing + updates multiple error paths to UUsageError.
src/uu/cut/locales/fr-FR.ftl Updates French diagnostic strings and adds new range-related message keys.
src/uu/cut/locales/en-US.ftl Updates English diagnostic strings and adds new range-related message keys.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/uu/cut/locales/fr-FR.ftl
Comment thread src/uu/cut/locales/en-US.ftl
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/misc/io-errors (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/retry (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/csplit/csplit-heap is now passing!

Comment thread tests/by-util/test_cut.rs Outdated
Comment thread src/uu/cut/src/cut.rs Outdated
Produce GNU's mode-aware messages (fields vs byte/character positions),
distinguish empty/invalid/decreasing/no-endpoint ranges, and align the
usage errors, all with the 'Try --help' hint.
Copilot AI review requested due to automatic review settings August 14, 2026 18:31

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/uu/cut/src/cut.rs:66

  • Doc comment mentions a -F option for field mode, but this utility only defines -f/--fields (no -F). This can mislead future maintainers when interpreting the mode-specific diagnostics logic.
/// GNU's range-list diagnostics, worded for field mode (`-f`/`-F`) or for
/// byte/character mode (`-b`/`-c`).

@codspeed-hq

codspeed-hq Bot commented Aug 14, 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

⚡ 5 improved benchmarks
❌ 1 regressed benchmark
✅ 347 untouched benchmarks
⏩ 50 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_wide_tree[(5000, 500)] 19.3 ms 20.2 ms -4.52%
Simulation numfmt_to_si[10000] 94.4 ms 91.3 ms +3.4%
Simulation numfmt_round_modes[("up", 10000)] 95.8 ms 92.7 ms +3.35%
Simulation numfmt_large_numbers_si[10000] 100.3 ms 97.2 ms +3.2%
Simulation numfmt_padding[(10000, 50)] 100.2 ms 97.1 ms +3.2%
Simulation numfmt_to_si_precision[10000] 97.5 ms 94.6 ms +3.11%

Tip

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


Comparing cut-diag (ce4cf44) with main (9516e99)

Open in CodSpeed

Footnotes

  1. 50 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.

@cakebaker
cakebaker merged commit 82e197a into main Aug 15, 2026
262 of 265 checks passed
@cakebaker
cakebaker deleted the cut-diag branch August 15, 2026 06:11
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.

3 participants