Skip to content

fmt: treat -N operands after -- as file names - #15837

Merged
cakebaker merged 1 commit into
uutils:mainfrom
MannXo:fix/15751-fmt-width-after-double-dash
Oct 26, 2026
Merged

cakebaker merged 1 commit into
uutils:mainfrom
MannXo:fix/15751-fmt-width-after-double-dash

Conversation

@MannXo

@MannXo MannXo commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

fmt -- -9 notes.txt took -9 as the obsolete -WIDTH option instead of a file name. clap's index_of does not count --, so the value looked exactly like fmt -9 notes.txt. Depending on the position it was dropped and used as the width, rejected with "invalid option", or (fmt -- -9 alone) the file list came out empty and stdin was read.

Operands after -- now go into a separate hidden positional with last(true), so they never reach the -WIDTH detection and are appended to the file list as they are. fmt -9 file and the "only when it is the first option" error are unchanged, and so is --help.

$ fmt -- -9 notes.txt
hidden text
the quick brown fox jumps
$ fmt notes.txt -- -9
the quick brown fox jumps
hidden text

test_fmt_negative_number_file_after_double_dash fails on main.

Closes #15751

@cakebaker
cakebaker merged commit 91d4f6a into uutils:main Oct 26, 2026
98 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks for your PR!

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.

fmt: a file named -9 after -- is treated as the -WIDTH option

2 participants