Skip to content

join: implement last-flag-wins for --check-order/--nocheck-order - #16074

Closed
naufalfx805-source wants to merge 2 commits into
uutils:mainfrom
naufalfx805-source:fix/join-check-order-last-wins
Closed

naufalfx805-source wants to merge 2 commits into
uutils:mainfrom
naufalfx805-source:fix/join-check-order-last-wins

Conversation

@naufalfx805-source

Copy link
Copy Markdown

Summary

  • Implement last-flag-wins semantics for --check-order / --nocheck-order in join, matching GNU coreutils behavior
  • Uses indices_of() to compare argument positions, following the existing pattern in ls, cp, and du
  • Previously --check-order always won regardless of command-line order

Repro (from #16004)

printf 'b\na\n' > a.txt
join --check-order --nocheck-order a.txt a.txt
# GNU: prints b and a, exits 0
# uutils before fix: "join: a.txt:2: is not sorted: a" exit 1
# uutils after fix: prints b and a, exits 0

Test plan

  • cargo test --test coreutils test_join::check_order_nocheck_order_last_wins
  • Test covers both orderings: --check-order --nocheck-order (nocheck wins) and --nocheck-order --check-order (check wins)
  • Existing join tests still pass

Fixes #16004

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gc3pLfULRGQmfBnqr3oo3D

GNU coreutils uses last-flag-wins semantics when both --check-order
and --nocheck-order are specified. Match that behavior by tracking
argument indices.

Fixes uutils#16004

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gc3pLfULRGQmfBnqr3oo3D
@sylvestre

Copy link
Copy Markdown
Contributor

I think you can do it with clap

@codspeed

codspeed Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 462 skipped benchmarks1


Comparing naufalfx805-source:fix/join-check-order-last-wins (fcdb428) with main (ba501a7)2

Open in CodSpeed

Footnotes

  1. 462 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 (5dd33b8) during the generation of this report, so ba501a7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Replace manual indices_of() comparison with clap's built-in
overrides_with mechanism, as suggested in review.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gc3pLfULRGQmfBnqr3oo3D
@naufalfx805-source

Copy link
Copy Markdown
Author

Good call — refactored to use overrides_with on both --check-order and --nocheck-order args. This lets clap handle the last-flag-wins semantics natively, so the parsing simplifies to plain get_flag() checks. Also fixed the rustfmt issue on the test file.

@cakebaker

Copy link
Copy Markdown
Contributor

Duplicate of #16013

Anyway, thanks for your PR!

@cakebaker cakebaker closed this Nov 2, 2026
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.

join: --nocheck-order after --check-order should win

3 participants