Skip to content

stat: use an empty -c or --printf format instead of the default - #16451

Open
binhvq wants to merge 2 commits into
uutils:mainfrom
binhvq:stat-empty-format
Open

binhvq wants to merge 2 commits into
uutils:mainfrom
binhvq:stat-empty-format

Conversation

@binhvq

@binhvq binhvq commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

An empty format was taken as "no format given", so stat -c '' and stat --printf= printed the default format. Like GNU, the default is now only used when neither option is given, so -c '' prints just the newline and --printf= prints nothing.

Closes #16450

Comment thread src/uu/stat/src/stat.rs Outdated
let use_printf = matches.contains_id(options::PRINTF);
// An empty format given by the user is still used instead of the default.
let user_format = matches
.get_one::<String>(if use_printf {

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.

the same if use_printf { PRINTF } else { FORMAT } is in given_option below, could be a single variable, no?

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.

Yes, it is a single format_option now, used for both.

@codspeed

codspeed Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 86.77%

1 warning, 1 note

⚠️ 120 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

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

❌ 2 regressed benchmarks
βœ… 403 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory socket_addrs_direct[100000] 8.6 KB 68 KB -87.29%
❌ Memory hostname_ip_lookup[100000] 9.1 KB 66.4 KB -86.24%

Tip

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


Comparing binhvq:stat-empty-format (0737d4e) with main (f4a9c63)2

Open in CodSpeed

Footnotes

  1. 70 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 (883bc3c) during the generation of this report, so f4a9c63 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

hubot pushed a commit to coreutils/coreutils that referenced this pull request Nov 15, 2026
* tests/stat/stat-printf.pl (f-empty, f-empty2, f-empty-terse)
(p-empty, fs-empty): New tests, ensuring an empty format is used
rather than the default one.

uutils/coreutils#16451

Link: #464

This branch has not been deployed

No deployments
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.

stat: an empty -c or --printf format falls back to the default format

2 participants