Skip to content

stat: let the last of --printf and --format win - #16012

Merged
sylvestre merged 3 commits into
uutils:mainfrom
Logic769:stat-last-of-printf-format-wins
Nov 4, 2026
Merged

sylvestre merged 3 commits into
uutils:mainfrom
Logic769:stat-last-of-printf-format-wins

Conversation

@Logic769

@Logic769 Logic769 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GNU stat lets the last of --printf and --format win, so stat --printf=X --format=Y a.txt prints Y followed by a newline. uutils instead always preferred --printf and printed X with no trailing newline.

This makes the two options mutually override so the last one on the command line wins, matching GNU.

Adds a regression test.

Closes #15993

@Logic769
Logic769 force-pushed the stat-last-of-printf-format-wins branch from d4bf48d to 3571c60 Compare October 30, 2026 13:03
Comment thread tests/by-util/test_stat.rs Resolved
@Logic769

Copy link
Copy Markdown
Contributor Author

Added tests for the reverse order: --format=Y --printf=X now asserts X wins, and -c is covered too. Ran the stat tests with cargo test --features feat_os_unix --test tests -- test_stat::.

@Logic769
Logic769 force-pushed the stat-last-of-printf-format-wins branch from db1aa59 to 6f29227 Compare November 2, 2026 01:03
Comment thread tests/by-util/test_stat.rs Resolved
@sylvestre

Copy link
Copy Markdown
Contributor

a bunch of jobs are failing

@Logic769
Logic769 force-pushed the stat-last-of-printf-format-wins branch from e649c07 to 1d50a00 Compare November 3, 2026 15:43
@Logic769

Logic769 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Failure

Tests job 126024590669:

error: failed to determine package fingerprint for build script for uucore v0.13.0 (.../src/uucore)
...
  Failed to read the directory at '.../src/uucore/uucore_fs_test_neq_8'
  No such file or directory (os error 2)
...
error: doctest failed, to rerun pass `-p uucore --doc`

The following extern location ... does not exist errors are cascading from this failure. The main test suite completed successfully (5912 passed; 0 failed).

Reason

This is the known uucore test-directory race: the parallel filesystem tests create and remove temporary directories under src/uucore (here uucore_fs_test_neq_8) while Cargo scans that package to compute the build-script fingerprint, so Cargo sees a directory that has already disappeared. The failure is in the uucore build/doctest setup, not in this PR's files (src/uu/stat/src/stat.rs, tests/by-util/test_stat.rs); there is no compilation error or assertion pointing to the stat change. This is unrelated to this PR and should be resolved by rerunning the job.

@sylvestre
sylvestre merged commit 397eb04 into uutils:main Nov 4, 2026
98 of 99 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.

stat: the last of --printf / --format should win

2 participants