head: propagate a write error from the -v filename header - #13996
Open
MsfPablo wants to merge 1 commit into
Open
head: propagate a write error from the -v filename header#13996MsfPablo wants to merge 1 commit into
MsfPablo wants to merge 1 commit into
Conversation
The two header writes around it use ?, but the filename went out via print_verbatim(file).unwrap(). A short name stays buffered and its error surfaces later at the checked flush; a name longer than the stdout buffer forces a flush mid-write, so the failure lands in the unwrap and aborts instead of being reported. Fixes uutils#13264
MsfPablo
force-pushed
the
head-header-write-error
branch
from
August 17, 2026 21:04
bb0d9ba to
7ea2b92
Compare
cakebaker
reviewed
Aug 18, 2026
Comment on lines
1074
to
1076
| /// Regression for #11972: a symlink that points to a regular file must | ||
| /// still be readable by head (the fd-based check must distinguish the | ||
| /// fd's mode, not the symlink's). |
Contributor
There was a problem hiding this comment.
The comment got disconnected from test_head_follows_symlink_to_regular_file.
|
GNU testsuite comparison: |
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.
Fixes #13264.
print_verbatim(file).unwrap()was the only unchecked write inprint_header— the==>and<==around it already use?. Switched it to?so the error travels the same way.The length threshold in the issue is what makes this reachable: a short filename stays in the stdout buffer and its write error surfaces later at a
?-checked flush, so only a name longer than the buffer forces a flush inside theunwrap.Now reports the write error and exits 1 instead of aborting.
Tests: an integration test following the
/dev/fullpattern already used intest_paste.rs, gated to Linux for the same reason.Worth being upfront: I develop on macOS, where
/dev/fullis not writable, so I could not execute that test locally. I did verify it compiles and runs by temporarily widening thecfg— it reaches the/dev/fullopen and fails only there — so CI is the real check on the assertion.