Skip to content

sort: let global -d override -i - #15643

Open
ozenyunus35 wants to merge 1 commit into
uutils:mainfrom
ozenyunus35:sort-d-overrides-i
Open

ozenyunus35 wants to merge 1 commit into
uutils:mainfrom
ozenyunus35:sort-d-overrides-i

Conversation

@ozenyunus35

Copy link
Copy Markdown
Contributor

Fixes #15578

-i should have no effect when -d is also given (GNU manual: "This option has no effect if the stronger --dictionary-order (-d) option is also given"). The key-option parser already does this for -k1,1di. The global options copied both flags into GlobalSettings, so sort -d -i used both filters and dropped the tabs and other control characters that -d keeps.

uumain now sets ignore_non_printing only when -d is not given. The incompatible-options check still uses both flags. Its messages were already the same as GNU's, e.g. options '-dn' are incompatible for -n -d -i.

export LC_ALL=C
printf '\tK\n7\n' | sort -d -i | od -An -c
# before:  7  \n  \t   K  \n
# after:  \t   K  \n   7  \n    (same as GNU 9.12)

I added test_dictionary_order_overrides_non_printing, which checks -d -i, -i -d, -di, -id and -di -k1. It fails without the change, and all test_sort tests and the uu_sort unit tests pass. I also compared -d -i, -i -d, -di, -id, -d -i -k1,1, -di -k2, -dir, -dif, -d and -i with GNU 9.12 on input with tabs and control characters. The output was the same for all of them.

cargo bench -p uu_sort shows no change against the merge base beyond run-to-run noise.

I used an AI assistant to help draft parts of the code and tests; I reviewed the changes and ran the tests myself.

@codspeed

codspeed Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning, 1 note

⚠️ 29 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

✅ 58 untouched benchmarks
⏩ 414 skipped benchmarks1


Comparing ozenyunus35:sort-d-overrides-i (c39edcc) with main (ff0c589)2

Open in CodSpeed

Footnotes

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

-i has no effect when -d is also given. The key options already did
this, but the global -d -i applied both filters and dropped the
control characters that -d keeps. Fixes uutils#15578.

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.

sort: global -i is not overridden by -d

1 participant