Repository navigation
fix(completions): exit cleanly when the output pipe closes - #726
Merged
dubadub merged 1 commit intoOct 14, 2026
Merged
Conversation
`clap_complete::generate` unwraps its writes internally, so `cook completions bash | head -1` panicked with BrokenPipe (exit 101). Generate into a buffer and write it to stdout, treating a broken pipe as done — the standard behaviour for a CLI whose reader went away. Closes #708
drawmeanelephant
force-pushed
the
fix/708-completions-broken-pipe
branch
from
October 13, 2026 14:33
e475199 to
aedc970
Compare
LeMyst
reviewed
Oct 13, 2026
LeMyst
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me. Generating into a Vec can't fail, so clap_complete's internal expect can't fire. The write_all to stdout then maps BrokenPipe to Ok, and since Rust ignores SIGPIPE the error does arrive as BrokenPipe.
🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.
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.
Closes #708
clap_complete::generateunwraps its writes internally, socook completions bash | head -1panicked with a BrokenPipe (exit 101). Now generates into a buffer and treatsErrorKind::BrokenPipeon the finalwrite_allas a clean exit — the standard behaviour for a CLI whose reader went away.Test plan
cook completions bash | head -1exits 0 (verified 3/3 runs, previously 101 8/8)cook completions zshstill prints a full script to stdout