stat: restore GNU's separators in the default output record - #101
Open
kelp wants to merge 4 commits into
Open
Conversation
Eight failing tests for issue #98. GNU's default_format puts a literal tab after the Size field and literal spaces after Blocks, IO Block, and Inode. Our format strings fold those separators into the pad widths, so they render identically for everyday values and vanish entirely once a field overflows its pad. Three unit tests cover the Size line and are ungated: one pins GNU's exact bytes for a 1383-byte file, two drive synthetic sizes and block counts past the pad. Two more cover the Device line with an 11-digit inode, Linux-gated like their issue-92 neighbours because the dev_t layout differs. The integration helper diffs the whole record against GNU for a regular file, a directory, and /dev/null, replacing the grep '^Device:' scoping those earlier tests needed. Red on both platforms: expected '\x09' after the size field, found '\x42' -- the B of Blocks. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VapqXpB1wtGk5Cb9KeMSok
The green phase fell back to a briefing embedded from an earlier dd run when none was passed in, so a bug fix could be implemented against another bug's notes. Re-scout instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VapqXpB1wtGk5Cb9KeMSok
GNU's default_format puts a literal tab after the Size field and literal spaces after Blocks, IO Block, and Inode. We folded each separator into the preceding pad width, which renders identically for everyday values and drops the separator entirely once a field overflows its pad: a 10GB file printed "10737418240Blocks:", and an 11-digit inode left one space before Links where GNU leaves two. Three format literals now match coreutils 9.5 byte for byte. On Linux, stat FILE is identical to /usr/bin/stat FILE for a regular file, a directory, and /dev/null, which lets the whole record be diffed against GNU instead of just the Device line. Fixes #98 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VapqXpB1wtGk5Cb9KeMSok
The EXAMPLES record rendered the separator as spaces, which is what the code used to emit. Also notes the fix in the changelog. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VapqXpB1wtGk5Cb9KeMSok
kelp
force-pushed
the
fix/stat-dev-minor-truncation
branch
from
July 30, 2026 02:51
6e52029 to
8ef8485
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GNU separates
Size:fromBlocks:with a tab, and follows theBlocks,IO BlockandInodefields with literal spaces. We foldedeach separator into the preceding column's pad width. That renders
identically for everyday values, which is why it went unnoticed, but the
separator disappears entirely once a field outgrows its pad:
10737418240Blocks:— no separator at allLinks:, not twoThe issue reported only the missing tab. The other two divergences are
the same defect and turned up while checking whether the rest of that
line was genuinely equivalent to GNU or merely coincidentally aligned
for the values tested. The fix is three format literals in
printDefaultFormat_sizeLineandprintDefaultFormat_deviceLine,matched against coreutils 9.5
default_format.Still divergent, out of scope here: GNU's
%Nshell-quoting of filenames (
File: 'my file'). We never quote.Tests
Red was verified on macOS and Linux before the fix, failing for the
right reason:
expected '\x09'after the size field,found '\x42'—the
BofBlocks.a 1383-byte file, two drive an 11-digit size and an 18-digit block
count past the pads.
both the plain and the
Device type:branch./usr/bin/statfor a regular file, a directory and/dev/null.That whole-record diff replaces the
grep '^Device:'scoping #92'stests had to settle for; those narrower checks stay as defense in depth.
zig build testByte-level check on Linux —
diffofcat -Aoutput against/usr/bin/statis identical for/etc/passwd,/dev/nulland/tmp.Also drops a stale embedded briefing from the
tdd-bugfixworkflow,which made the green phase fall back to another bug's notes when none
was passed in.
Closes #98
🤖 Generated with Claude Code
https://claude.ai/code/session_01VapqXpB1wtGk5Cb9KeMSok