Repository navigation
sort: reject conflicting -t separators - #15707
Merged
Merged
Conversation
The -t argument kept the default set-action together with args_override_self, so a later -t silently replaced an earlier one. Collect every occurrence and fail with "incompatible tabs" (exit 2) when they differ, the same way repeated -o is handled. Repeating the same separator keeps working. Fixes uutils#15598
sylvestre
reviewed
Oct 24, 2026
|
|
||
| // Prevent -t/--field-separator from being given different values. Raw | ||
| // values suffice: `\0` is the only spelling rewritten later, and argv cannot hold a NUL. | ||
| if matches |
Contributor
There was a problem hiding this comment.
almost the same code as the -o check just above, could be dedup in a small helper, no?
Contributor
Author
There was a problem hiding this comment.
Done, extracted a helper.
Contributor
|
Thanks for your PR |
xtqqczze
reviewed
Oct 25, 2026
|
|
||
| #[test] | ||
| fn test_error_on_incompatible_separators() { | ||
| let cases: [&[&str]; 3] = [ |
Collaborator
There was a problem hiding this comment.
@fixfon could you please follow-up by converting the test cases to #[rstest] cases
hubot
pushed a commit
to coreutils/coreutils
that referenced
this pull request
Oct 25, 2026
* tests/sort/sort.pl (tab-dup1, tab-dup2, tab-incompat1) (tab-incompat2, tab-incompat3): New tests. Ensure differing -t separators, including NUL, evoke "incompatible tabs", while repeating the same one is accepted. uutils/coreutils#15707 Link: #399
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15598
sort -t@ -t! fileused to sort with!and say nothing. Because ofargs_override_self(true), the second-tquietly replaced the first, anduumainonly ever saw the last value throughget_one. Now-tisArgAction::Append, and if two separators differ sort exits with code 2 and printssort: incompatible tabs, which matches GNU. I copied the existing check for repeated-othat gives "multiple output files specified". Passing the same separator twice (-t: -t:) still works.The comparison runs on the raw values, before the one-character check. So
-t ab -t cdnow givesincompatible tabsinstead of "separator must be exactly one character long". Both exit with code 2.I added two tests to
tests/by-util/test_sort.rs. One checks that different separators fail, given as-t@,-t @and--field-separator=@. The other checks that the same separator given twice still sorts. The first test fails without the fix, andtest_sortpasses with it.cargo fmtandclippy -D warningsare clean. I've only tested this on macOS. The French string infr-FR.ftlis my own translation.