Skip to content

printf: take --help/--version as options only when alone - #16385

Merged
sylvestre merged 2 commits into
uutils:mainfrom
binhvq:printf-help-sole-operand
Nov 18, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
binhvq:printf-help-sole-operand

Conversation

@binhvq

@binhvq binhvq commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Closes #16384

--help and --version were taken as options as long as they came first, so printf --version x printed the version. Like GNU, only treat them as options when they are the only argument; otherwise they are the format.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/id/smack is no longer failing!
Congrats! The gnu test tests/mkdir/smack-no-root is no longer failing!
Congrats! The gnu test tests/mkdir/smack-root is no longer failing!
Congrats! The gnu test tests/df/skip-rootfs is now passing!

@sylvestre

Copy link
Copy Markdown
Contributor

thanks for tackling this!
Style and Lint is red, most likely because of clippy on the new match (see inline).

Comment thread src/uu/printf/src/printf.rs Outdated
match args.get(1) {
// `--help` and `--version` are options only when they are the sole
// argument; otherwise they are the format.
Some(arg) if args.len() == 2 && (arg == "--help" || arg == "--version") => {}

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.

clippy is red, i think it's match_same_arms (this arm and _ are both {})
maybe a single if that inserts the -- would be simpler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to a single if. The red clippy was actually needless_bool in install.rs from main at that time (fixed on main in 124e313); clippy 1.100 is clean on this branch.

@sylvestre
sylvestre force-pushed the printf-help-sole-operand branch from 24ede43 to d62c9f6 Compare November 16, 2026 08:14
@codspeed

codspeed Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will regress 1 benchmark

1 warning, 1 note

⚠️ 46 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ This run is excluded from the branch history

This commit was force-pushed, so this run no longer appears in the branch's performance history.

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 79 untouched benchmarks
🆕 4 new benchmarks
⏩ 393 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ file_tz_abbreviations 17.6 ms 18.2 ms -3.25%
⚡ factor_small_factors_and_a_large_prime 1,012.7 µs 682 µs +48.49%
⚡ df_deep_directory 927.4 µs 881.1 µs +5.26%
🆕 factor_batch_of_largest_u64s N/A 557.4 ms N/A
🆕 factor_batch_of_semiprimes N/A 794.2 ms N/A
🆕 factor_batch_of_small_numbers N/A 138.6 ms N/A
🆕 factor_batch_of_smallest_u128s N/A 516.3 ms N/A

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing binhvq:printf-help-sole-operand (24ede43) with main (b5223da)2

Open in CodSpeed

Footnotes

  1. 393 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (5159884) during the generation of this report, so b5223da was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@sylvestre
sylvestre merged commit 8800300 into uutils:main Nov 18, 2026
102 checks passed
@sylvestre

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.

printf: --help/--version are options even when they are not the only argument

2 participants