Skip to content

sort: handle clustered short options ending in attached '-t' - #14158

Open
MadeNavaneeth wants to merge 1 commit into
uutils:mainfrom
MadeNavaneeth:fix/sort-clustered-t-separator
Open

sort: handle clustered short options ending in attached '-t'#14158
MadeNavaneeth wants to merge 1 commit into
uutils:mainfrom
MadeNavaneeth:fix/sort-clustered-t-separator

Conversation

@MadeNavaneeth

Copy link
Copy Markdown
Contributor

Summary

Extends the -t= rewrite in sort to handle clustered short options like -nt= and -bt=x.

The problem

GNU sort splits -nt=5 into flags -n plus -t taking =5 verbatim, yielding the expected multi-character separator error. uutils instead stripped the leading =, silently accepting 5 as a single-character separator.

The fix

When a short-option cluster ends in t and every earlier character is a value-less flag (bCcdfghimMnRrsuz), 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.

Tests added

  • test_separator_clustered_attached-nt=5 correctly errors on multi-char separator =5
  • test_separator_clustered_attached_b-bt=x correctly errors on multi-char separator =x
  • test_separator_clustered_still_sorts-nt= -k 2 still sorts correctly with = separator

Verification

  • ✅ All 3 new tests pass
  • ✅ 203/204 sort tests pass (1 pre-existing locale failure)
  • cargo clippy -p uu_sort -- -D warnings clean

Follow-up to #14144 / #14120

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/retry (passes in this run but fails in the 'main' branch)

Comment thread src/uu/sort/src/sort.rs
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.

@sylvestre sylvestre Aug 26, 2026

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.

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
MadeNavaneeth force-pushed the fix/sort-clustered-t-separator branch from ce9f9d8 to 52e3c09 Compare August 27, 2026 04:50
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.

2 participants