Skip to content

stat: default output omits GNU's tab after the Size field #98

Description

@kelp

Summary

GNU stat's default output separates the Size: field from Blocks: with a tab; vibeutils uses spaces only. Every other line of the default record matches GNU byte-for-byte, so this single missing \t is the only thing preventing whole-record parity.

Evidence

Linux (orb ubuntu), GNU coreutils 9.5, cat -A on line 2:

--- /etc/passwd ---
ours:  Size: 1383      Blocks: 8          IO Block: 4096   regular file$
GNU:   Size: 1383      ^IBlocks: 8          IO Block: 4096   regular file$

--- /dev/null ---
ours:  Size: 0         Blocks: 0          IO Block: 4096   character special file$
GNU:   Size: 0         ^IBlocks: 0          IO Block: 4096   character special file$

With the field widths we already use, the rendered columns line up either way, so this is invisible unless you diff the bytes.

Where

printDefaultFormat_sizeLine, src/stat.zig:958-966:

try writer.print("  Size: {d: <10}Blocks: {d: <11}IO Block: {d: <7}{s}\n", .{

GNU's format is Size: %-10s\tBlocks: %-10b IO Block: %-6o %F — note the \t after the size and the single spaces before IO Block: and the file type, versus our padded widths. Worth checking whether the rest of that line is truly equivalent or merely coincidentally aligned for the values tested.

How it surfaced

Found while fixing #92. The integration test added there (_test_stat_dev_type_null_parity) wanted full default-output parity against GNU for /dev/null, but had to be scoped to grep '^Device:' because this Size-line divergence fails whole-record comparison for an unrelated reason. Fixing this would let that test — and any future one — compare the entire record.

Test

A Linux-gated integration test in tests/utilities/stat_test.sh diffing our full stat FILE output against /usr/bin/stat FILE, in the same differential style as the existing _test_stat_dev_parity. It should cover a regular file, a directory, and a character special file, since GNU varies the format string by file type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions