From 3eb06e16855e8a678f9e9483f9987c562be6870e Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 31 Aug 2026 16:37:36 +0200 Subject: [PATCH] fix: silence /dev/tty redirect errors when no tty is attached Redirections are applied left to right, so `> /dev/tty 2>/dev/null` opens /dev/tty while stderr is still the inherited one. When /dev/tty is unavailable the shell's "No such device or address" message escapes to stderr before 2>/dev/null takes effect. Swapping the order to `2>/dev/null > /dev/tty` mutes stderr first, so the failed open is silent. Exit status and the JSON fallback path are unchanged. This surfaces on Windows/Git Bash, where the Stop hook has no controlling terminal and every turn prints: emit-terminal-sequence.sh: line 82: /dev/tty: No such device or address Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01PWTCPGfRHRHJxiuXUjxP6X --- plugins/warp/scripts/emit-terminal-sequence.sh | 4 ++-- plugins/warp/scripts/legacy/warp-notify.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/warp/scripts/emit-terminal-sequence.sh b/plugins/warp/scripts/emit-terminal-sequence.sh index b6a83b9..4ddc113 100644 --- a/plugins/warp/scripts/emit-terminal-sequence.sh +++ b/plugins/warp/scripts/emit-terminal-sequence.sh @@ -72,14 +72,14 @@ emit_terminal_sequence() { # Known-old Claude Code — /dev/tty is the only safe path. # Emitting terminalSequence here would be rejected by the Stop # hook validator as an unknown field. - printf '%s' "$seq" > /dev/tty 2>/dev/null || true + printf '%s' "$seq" 2>/dev/null > /dev/tty || true fi return 0 fi # Unknown Claude Code version — try /dev/tty, fall back to JSON # as a best-effort attempt for new CC without version detection. - if printf '%s' "$seq" > /dev/tty 2>/dev/null; then + if printf '%s' "$seq" 2>/dev/null > /dev/tty; then return 0 fi jq -nc --arg seq "$seq" '{terminalSequence: $seq}' diff --git a/plugins/warp/scripts/legacy/warp-notify.sh b/plugins/warp/scripts/legacy/warp-notify.sh index 6ca0588..dfdede2 100755 --- a/plugins/warp/scripts/legacy/warp-notify.sh +++ b/plugins/warp/scripts/legacy/warp-notify.sh @@ -7,4 +7,4 @@ BODY="${2:-}" # OSC 777 format: \033]777;notify;;<body>\007 # Write directly to /dev/tty to ensure it reaches the terminal -printf '\033]777;notify;%s;%s\007' "$TITLE" "$BODY" > /dev/tty 2>/dev/null || true +printf '\033]777;notify;%s;%s\007' "$TITLE" "$BODY" 2>/dev/null > /dev/tty || true