Repository navigation
Conversation
--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
| } | ||
|
|
||
| // 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) |
There was a problem hiding this comment.
almost the same check as -o just above, could be a small shared helper, no?
There was a problem hiding this comment.
Done, extracted a helper.
Merging this PR will not alter performance1 warning, 1 note
Comparing Footnotes
|
…le-compress # Conflicts: # src/uu/sort/locales/en-US.ftl # src/uu/sort/locales/fr-FR.ftl # src/uu/sort/src/sort.rs
Fixes #15594
sort --compress-program pwd --compress-program python3 fileused to sort withpython3and say nothing.args_override_self(true)let the later value silently replace the earlier one, anduumainread the option withget_one.--compress-programis nowArgAction::Append, and if two values differ sort exits 2 withsort: multiple compress programs specified, like GNU. The check sits right next to the existing one for repeated-oand 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 andtest_sortpasses with it.cargo fmtandclippy -D warningsare clean. Tested on macOS only. Thefr-FR.ftlstring is my own translation.