sort: handle clustered short options ending in attached '-t' - #14158
Open
MadeNavaneeth wants to merge 1 commit into
Open
sort: handle clustered short options ending in attached '-t'#14158MadeNavaneeth wants to merge 1 commit into
MadeNavaneeth wants to merge 1 commit into
Conversation
|
GNU testsuite comparison: |
sylvestre
reviewed
Aug 26, 2026
Comment on lines
+2134
to
+2139
| // Clustered form where `-t` consumes the rest of the argument, | ||
| // e.g. -nt=5: GNU splits this into flags `-n` plus `-t` taking | ||
| // `=5` verbatim (a multi-character separator error). Split into | ||
| // `-<flags>t` and `<rest>` so clap passes the value through | ||
| // unstripped. Only applied when every character before `t` is a | ||
| // valueless flag, keeping -k/-o/-S arguments intact. |
Contributor
There was a problem hiding this comment.
please, make it shorter
GNU splits 'sort -nt=5' into flags '-n' plus '-t' taking '=5' verbatim, yielding the expected multi-character separator error. Clap instead stripped the leading '=', silently accepting '5' as a single-character separator. Extend the '-t=' rewrite: when a short-option cluster ends in 't' and every earlier character is a value-less flag, split into '-<flags>t' plus the remainder as a separate argument, which clap passes through unstripped. Value-taking shorts (-k/-o/-S) are never touched since only value-less flags precede the rewrite point. Follow-up to uutils#14144 / uutils#14120.
MadeNavaneeth
force-pushed
the
fix/sort-clustered-t-separator
branch
from
August 27, 2026 04:50
ce9f9d8 to
52e3c09
Compare
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.
Summary
Extends the
-t=rewrite insortto handle clustered short options like-nt=and-bt=x.The problem
GNU
sortsplits-nt=5into flags-nplus-ttaking=5verbatim, yielding the expected multi-character separator error. uutils instead stripped the leading=, silently accepting5as a single-character separator.The fix
When a short-option cluster ends in
tand every earlier character is a value-less flag (bCcdfghimMnRrsuz), split into-<flags>tplus the remainder as a separate argument, which clap passes through unstripped. Value-taking shorts (-k/-o/-S) are never touched since only value-less flags precede the rewrite point.Tests added
test_separator_clustered_attached—-nt=5correctly errors on multi-char separator=5test_separator_clustered_attached_b—-bt=xcorrectly errors on multi-char separator=xtest_separator_clustered_still_sorts—-nt= -k 2still sorts correctly with=separatorVerification
cargo clippy -p uu_sort -- -D warningscleanFollow-up to #14144 / #14120