Skip to content

stat: add the 0 of %#a only when the digits do not start with one - #16393

Merged
sylvestre merged 3 commits into
uutils:mainfrom
binhvq:stat-alt-octal-precision
Nov 14, 2026
Merged

sylvestre merged 3 commits into
uutils:mainfrom
binhvq:stat-alt-octal-precision

Conversation

@binhvq

@binhvq binhvq commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Closes #16392

%#a always put a 0 in front of the octal digits, so %#.4a printed 00644 and %#a printed 00 for mode 0. Like printf's %#o, add it only when the digits, after the precision, do not already start with a 0.

@sylvestre

Copy link
Copy Markdown
Contributor

clippy is sad on 4 jobs :)

@binhvq

binhvq commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

The clippy errors are in install.rs and stty.rs, not in stat: install is fixed on main by #16395 and stty by #16402. I'll merge main once #16402 is in.

@binhvq

binhvq commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Merged main now that #16402 is in, so the clippy jobs should be green.

use std::os::unix::fs::PermissionsExt;

let (at, mut ucmd) = at_and_ucmd!();
at.touch("f");

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.

could use at.set_mode() and pass both files in a single stat call, 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, done: both files now go through set_mode and a single stat call.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/usage_vs_getopt (fails in this run but passes in the 'main' branch)

@sylvestre
sylvestre merged commit de0c941 into uutils:main Nov 14, 2026
195 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

hubot pushed a commit to coreutils/coreutils that referenced this pull request Nov 15, 2026
* tests/stat/stat-fmt.sh: Check %#a with various precisions and
widths, including for a mode of 0.

uutils/coreutils#16393

Link: #463
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: %#a adds a 0 even when the octal digits already start with one

2 participants