pr: accept -e at the end of a short flag cluster - #13949
Merged
Merged
Conversation
Contributor
|
Please contribute to clap instead of working around at here. |
|
Binary size comparison: |
m0g3r
force-pushed
the
pr-expand-tabs-flag-cluster
branch
from
August 14, 2026 19:02
b121e71 to
4984383
Compare
`-e` takes an optional attached argument, which clap cannot express, so `recreate_arguments` fills in the default. It only recognised an argument starting with `-e`, so a cluster such as `-tre` reached clap as a bare `-e` and was rejected with "a value is required for --expand-tabs". Match a cluster of value-less short flags ending in `e` instead, and append the default rather than replacing the whole argument. Options that take a value of their own are excluded so `-se` still means `-s e`. Fixes uutils#13895 Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
sylvestre
force-pushed
the
pr-expand-tabs-flag-cluster
branch
from
August 15, 2026 07:11
4984383 to
5835de8
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.
Fixes #13895.
pr -trefailed witha value is required for '--expand-tabs <[CHAR][WIDTH]>' but none was supplied, while GNU printsoi.-etakes an optional attached argument, which clap cannot express, sorecreate_argumentsfills in the default before parsing. Its check was^-e, which only matches an argument that starts with-e, so-eat the end of a cluster like-trewas never given the default and reached clap bare.Now it matches a cluster of value-less short flags ending in
eand appends the default instead of replacing the whole argument, so-trebecomes-tre\t8and a bare-estill becomes-e\t8. Options that take a value are excluded from the cluster so-sekeeps meaning-s e.I used
recreate_argumentsrather thannum_args(0..=1)as #13900 does for-n: withnum_args(0..=1)a bare-eswallows the following operand, sopr -t -e filereports the file name as an invalid-eargument. The second test below guards that.Test
test_expand_tab_at_end_of_short_flag_clusterfails on main with the error from the issue and passes with this change. The fullprsuite passes, 246 tests, andcargo clippy -p uu_pr --all-targets -- -D warningsis clean.Written with AI assistance. I have reviewed the diff and checked the behaviour against GNU
prmyself.