summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Vincent <jesse@primeradiant.com>2026-09-26 12:11:21 -0700
committerJesse Vincent <jesse@primeradiant.com>2026-09-26 12:11:21 -0700
commitf5f695329400a98ad3db7d5e6c5878da4c2091ee (patch)
treefc3facbf342bcd68cc74f232f4202c66aab082c8
parentc5cc551e244458581e68bb08f67f912f2ec195dd (diff)
Explain why session-start pipes printf through cat
Three open PRs (#2115, #2349, #2367) removed the | cat pipes as no-op subprocess spawns, which would bring back the Windows EPIPE diagnostic fixed in d72560e (#1612). Say so next to the code.
-rwxr-xr-xhooks/session-start8
1 files changed, 8 insertions, 0 deletions
diff --git a/hooks/session-start b/hooks/session-start
index 083cb23..ffafd64 100755
--- a/hooks/session-start
+++ b/hooks/session-start
@@ -36,6 +36,14 @@ session_context="<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the
#
# Uses printf instead of heredoc to work around bash 5.3+ heredoc hang.
# See: https://github.com/obra/superpowers/issues/571
+#
+# Each printf is piped through `cat` on purpose, to absorb EPIPE on Windows.
+# On Windows + Git Bash, the harness can close the hook's stdout before
+# printf finishes, and Git Bash's printf reports that EPIPE as
+# "printf: write error: Permission denied", which `set -euo pipefail` lets
+# escape as a startup diagnostic every session. Letting cat receive the
+# EPIPE keeps it out of the hook's error path. Keep the `| cat` even when
+# trimming subprocess spawns. See: https://github.com/obra/superpowers/issues/1612
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
# Cursor sets CURSOR_PLUGIN_ROOT (may also set CLAUDE_PLUGIN_ROOT)
printf '{\n "additional_context": "%s"\n}\n' "$session_context" | cat