fix(warp): stop /dev/tty ENXIO error leaking to the user#75
Open
xpepper wants to merge 1 commit into
Open
Conversation
When there's no controlling terminal (e.g. a SessionStart hook subprocess before CLAUDE_CODE_VERSION is resolvable), the /dev/tty write fails with ENXIO. `> /dev/tty 2>/dev/null` can't suppress bash's own "Device not configured" diagnostic in that case: bash reports the failed redirect before it applies the following 2>/dev/null, so the raw error still reaches the user's terminal on session start. Wrapping the write in a brace group before the 2>/dev/null redirect applies the suppression to the whole group up front, so the error is caught. Behavior (return codes, JSON fallback) is unchanged; verified against the existing test-hooks.sh suite (57/57 passing) plus a direct before/after repro with no controlling tty and an unset CLAUDE_CODE_VERSION.
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.
Summary
emit-terminal-sequence.shwrites to/dev/ttyas a fallback whenCLAUDE_CODE_VERSIONcan't be resolved (e.g. duringSessionStart, before the version-detection env caching kicks in). When the hook subprocess has no controlling terminal, opening/dev/ttyfails withENXIO, and bash reports"line N: /dev/tty: Device not configured"itself — to the original stderr, before the script's own2>/dev/nullon that same command takes effect. The result is a raw bash error printed to the user on session start, even though the script goes on to correctly fall back to theterminalSequenceJSON output.2>/dev/null, so the suppression covers the whole group (including the redirect's own open failure) rather than trying to suppress errors on a redirect that fails before the following one applies.Repro
Before/after against this repo's
emit_terminal_sequence, no controlling tty, unsetCLAUDE_CODE_VERSION:Test plan
plugins/warp/tests/test-hooks.sh: 57/57 passing, unchanged