Skip to content

uniq: accept a repeated -D/--all-repeated, last one wins - #13898

Open
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-uniq-repeated-all-repeated
Open

uniq: accept a repeated -D/--all-repeated, last one wins#13898
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-uniq-repeated-all-repeated

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown

Problem

Passing -D/--all-repeated more than once fails:

$ printf 'a\na\nb\nb\nc\n' | uniq -D --all-repeated=separate
error: the argument '--all-repeated[=<delimit-method>]' cannot be used multiple times

-D and --all-repeated are the same option, and clap rejects the repeat. GNU
uniq accepts a repeated option and uses the last occurrence, so a script that
mixes the short and long form works there but fails here.

Fix

Add .overrides_with(options::ALL_REPEATED) so a later occurrence overrides an
earlier one, matching GNU.

Verification

$ printf 'a\na\nb\nb\nc\n' | uniq -D --all-repeated=separate
a
a

b
b

Output matches GNU coreutils (guniq) exactly. Added a regression test; the
full test_uniq suite passes and cargo fmt / cargo clippy are clean.

@codspeed-hq

codspeed-hq Bot commented Aug 13, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 0.1%

⚠️ 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
✅ 351 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_summarize_balanced_tree[(5, 4, 10)] 16.3 ms 16.9 ms -3.3%
Simulation ls_recursive_balanced_tree[(6, 4, 15)] 120.7 ms 117 ms +3.21%

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-uniq-repeated-all-repeated (67e88c1) with main (d8bee62)

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.

Comment thread src/uu/uniq/src/uniq.rs Outdated
.default_missing_value("none")
.require_equals(true),
.require_equals(true)
// GNU uniq accepts a repeated -D/--all-repeated and uses the last

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.

not sure we need 3 lines comment here

please make it shorter

GNU uniq accepts -D/--all-repeated given more than once and uses the last
occurrence. clap rejected the second one, so a script mixing the short -D and
the long --all-repeated form failed with "cannot be used multiple times". Add
overrides_with so a repeat overrides the earlier value instead of erroring.
@AlejandroCoronadoN
AlejandroCoronadoN force-pushed the fix-uniq-repeated-all-repeated branch from 250e71b to 67e88c1 Compare August 13, 2026 16:11
@AlejandroCoronadoN

Copy link
Copy Markdown
Author

Thanks! Shortened the comment to a single line.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 148.97 MB (-132 KB, -0.09%)

Significant per-binary changes:
  [           1.10 MB ->    1.18 MB  (+76 KB, +6.74%)
  test        1.10 MB ->    1.18 MB  (+76 KB, +6.74%)
  install     1.25 MB ->    1.32 MB  (+72 KB, +5.62%)
  mkdir       1.10 MB ->    1.17 MB  (+72 KB, +6.38%)
  mkfifo      1.09 MB ->    1.16 MB  (+72 KB, +6.45%)
  mknod       1.10 MB ->    1.17 MB  (+72 KB, +6.41%)
  chmod       1.15 MB ->    1.22 MB  (+68 KB, +5.76%)

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/tail/pipe-f is now being skipped but was previously passing.

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.

2 participants