Skip to content

stat: accept a hyphen-leading --format/--printf/-c value - #14323

Open
arbelonson-source wants to merge 1 commit into
uutils:mainfrom
arbelonson-source:fix/stat-format-hyphen-value
Open

stat: accept a hyphen-leading --format/--printf/-c value#14323
arbelonson-source wants to merge 1 commit into
uutils:mainfrom
arbelonson-source:fix/stat-format-hyphen-value

Conversation

@arbelonson-source

Copy link
Copy Markdown
Contributor

What

--format (-c) and --printf's value was rejected as an
unrecognized flag when given as its own argument:

$ stat --format -x /tmp

# GNU: outputs "-x" literally (a format string with no % directives)
-x

# uutils, before this PR:
error: unexpected argument '-x' found
  tip: to pass '-x' as a value, use '-- -x'

The attached forms (-c-x, --format=-x) already worked; only the
separate-argument form broke -- the same allow_hyphen_values gap
already fixed this session for several other options (sort --parallel, nl's numeric options, ptx --gap-size/--width, join -t, csplit --suffix-format, paste -d, numfmt
-d/--suffix/--padding).

Testing

  • cargo test --features stat -p uu_stat / full tests/by-util/test_stat.rs suite: 44 passed, 0 failed.
  • Added a regression test covering all three spellings (--format, --printf, -c) with the separate-argument hyphen-leading case.
  • Manually diffed --format -x, --printf -x, -c -x against GNU stat 9.11 under LC_ALL=C.
  • cargo clippy -p uu_stat --all-targets -- -D warnings and cargo fmt --check: clean.

This PR was written with AI assistance (Claude Opus 5, via Claude Code). I've tested the changes but please review the code carefully.

--format (-c) and --printf's value was rejected as an unrecognized
flag when given as its own argument (stat --format -%n f, not the
attached -c-%n or --format=-%n): the Args were missing
allow_hyphen_values, the same gap already fixed this session for
several other options. GNU's own stat accepts any argument as the
format string regardless of its first character.

AI-assisted-by: Claude Opus 5, via Claude Code
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/io-errors (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/retry (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/pr/bounded-memory is now passing!

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.

1 participant