Skip to content

sort: reject conflicting --compress-program values - #15708

Open
fixfon wants to merge 4 commits into
uutils:mainfrom
fixfon:fix/15594-sort-multiple-compress
Open

fixfon wants to merge 4 commits into
uutils:mainfrom
fixfon:fix/15594-sort-multiple-compress

Conversation

@fixfon

@fixfon fixfon commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #15594

sort --compress-program pwd --compress-program python3 file used to sort with python3 and say nothing. args_override_self(true) let the later value silently replace the earlier one, and uumain read the option with get_one. --compress-program is now ArgAction::Append, and if two values differ sort exits 2 with sort: multiple compress programs specified, like GNU. The check sits right next to the existing one for repeated -o and works the same way, so giving the same program twice is still fine.

I added two tests to tests/by-util/test_sort.rs: different programs fail, and the same program twice still sorts. The input is small enough that the program is never spawned, so neither test depends on the platform. The first test fails without the fix and test_sort passes with it. cargo fmt and clippy -D warnings are clean. Tested on macOS only. The fr-FR.ftl string is my own translation.

--compress-program was a plain single-value option and sort uses
args_override_self, so a later occurrence silently replaced the
earlier one. Collect every occurrence like -o does and fail with
exit status 2 when two of them differ. Repeating the same program
still works.

Fixes uutils#15594
Comment thread src/uu/sort/src/sort.rs Outdated
}

// Same as -o: repeating --compress-program is fine as long as the value is the same
if let Some(mut progs) = matches.get_many::<String>(options::COMPRESS_PROG)

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.

almost the same check as -o just above, could be a small shared helper, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, extracted a helper.

@codspeed

codspeed Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning, 1 note

⚠️ 28 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 fixfon:fix/15594-sort-multiple-compress (1a640e2) 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. ↩

…le-compress

# Conflicts:
#	src/uu/sort/locales/en-US.ftl
#	src/uu/sort/locales/fr-FR.ftl
#	src/uu/sort/src/sort.rs

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.

bug(sort): Multiple compress programs allowed

2 participants