-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
stat: --printf option does not support precision in certain format strings #3233
Description
The --printf argument to stat does not seem to correctly support precision specifiers in format strings.
For example, after creating a file with touch f...
GNU stat:
$ stat --printf='%.1Y\n' f
1646795086.4
uutils stat:
$ ./target/release/stat --printf='%.1Y\n' f
1
From the documentation
The ‘%W’, ‘%X’, ‘%Y’, and ‘%Z’ formats accept a precision preceded by a period to specify the number of digits to print after the decimal point. For example, ‘%.3X’ outputs the access timestamp to millisecond precision. If a period is given but no precision, stat uses 9 digits, so ‘%.X’ is equivalent to ‘%.9X’. When discarding excess precision, timestamps are truncated toward minus infinity.
-- https://www.gnu.org/software/coreutils/manual/html_node/stat-invocation.html
Edit: this is causing a test failure in the GNU test file tests/stat/stat-nanoseconds.sh.