Skip to content

stat: --printf option does not support precision in certain format strings #3233

@jfinkels

Description

@jfinkels

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions