Skip to content

pr: accept -e at the end of a short flag cluster - #13949

Merged
sylvestre merged 1 commit into
uutils:mainfrom
m0g3r:pr-expand-tabs-flag-cluster
Aug 16, 2026
Merged

pr: accept -e at the end of a short flag cluster#13949
sylvestre merged 1 commit into
uutils:mainfrom
m0g3r:pr-expand-tabs-flag-cluster

Conversation

@m0g3r

@m0g3r m0g3r commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #13895.

pr -tre failed with a value is required for '--expand-tabs <[CHAR][WIDTH]>' but none was supplied, while GNU prints oi.

-e takes an optional attached argument, which clap cannot express, so recreate_arguments fills in the default before parsing. Its check was ^-e, which only matches an argument that starts with -e, so -e at the end of a cluster like -tre was never given the default and reached clap bare.

Now it matches a cluster of value-less short flags ending in e and appends the default instead of replacing the whole argument, so -tre becomes -tre\t8 and a bare -e still becomes -e\t8. Options that take a value are excluded from the cluster so -se keeps meaning -s e.

I used recreate_arguments rather than num_args(0..=1) as #13900 does for -n: with num_args(0..=1) a bare -e swallows the following operand, so pr -t -e file reports the file name as an invalid -e argument. The second test below guards that.

Test

test_expand_tab_at_end_of_short_flag_cluster fails on main with the error from the issue and passes with this change. The full pr suite passes, 246 tests, and cargo clippy -p uu_pr --all-targets -- -D warnings is clean.


Written with AI assistance. I have reviewed the diff and checked the behaviour against GNU pr myself.

@oech3

oech3 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Please contribute to clap instead of working around at here.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 149.02 MB (+92 KB, +0.06%)

Significant per-binary changes:
  [           1.10 MB ->    1.18 MB  (+76 KB, +6.74%)
  mkdir       1.10 MB ->    1.17 MB  (+76 KB, +6.76%)
  mknod       1.09 MB ->    1.17 MB  (+76 KB, +6.79%)
  test        1.10 MB ->    1.18 MB  (+76 KB, +6.74%)
  install     1.25 MB ->    1.32 MB  (+72 KB, +5.62%)
  mkfifo      1.09 MB ->    1.16 MB  (+72 KB, +6.45%)
  chmod       1.15 MB ->    1.22 MB  (+68 KB, +5.76%)

@m0g3r
m0g3r force-pushed the pr-expand-tabs-flag-cluster branch from b121e71 to 4984383 Compare August 14, 2026 19:02
`-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
sylvestre force-pushed the pr-expand-tabs-flag-cluster branch from 4984383 to 5835de8 Compare August 15, 2026 07:11
@sylvestre
sylvestre merged commit 5633f03 into uutils:main Aug 16, 2026
167 of 168 checks passed
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.

pr -tre requires a value, but gnu's implementation doesn't

3 participants