Summary
All hook scripts use #!/bin/bash as their shebang. On macOS, /bin/bash is permanently pinned to bash 3.2.57 (Apple won't ship newer versions due to GPLv3 licensing). Users who install a modern bash (4.x/5.x) via Homebrew or similar have their $PATH configured to use the newer version, but the hardcoded shebang bypasses $PATH entirely.
When bash runs a script (non-interactive shell), it sources $BASH_ENV if set. Because the hooks force /bin/bash 3.2, $BASH_ENV gets sourced under bash 3.2 instead of the user's expected bash version. Any bash 4+ or 5+ features in the $BASH_ENV target file will fail or behave unexpectedly.
How it breaks
- User has bash 5.x installed (e.g.
/opt/homebrew/bin/bash) and $PATH prioritizes it
- User has
$BASH_ENV set, pointing to a file that uses modern bash features
- Claude Code hook fires → kernel sees
#!/bin/bash → launches /bin/bash (3.2.57)
- Bash 3.2 inherits the environment, sees
$BASH_ENV, and sources the file
- Modern bash features fail under 3.2 (associative arrays,
${var,,}, |&, readarray, declare -g, etc.)
Reproduction
# Confirm macOS system bash version
/bin/bash --version
# GNU bash, version 3.2.57(1)-release (arm64-apple-darwin...)
# Confirm user's actual bash
bash --version
# GNU bash, version 5.2.37(1)-release ...
# If BASH_ENV is set and its target uses any bash 4+ feature,
# hook scripts will error or produce unexpected behavior
echo $BASH_ENV
Affected files
All .sh scripts under plugins/warp/scripts/ and plugins/warp/scripts/legacy/:
on-post-tool-use.sh
on-session-start.sh
on-prompt-submit.sh
on-stop.sh
on-permission-request.sh
on-notification.sh
build-payload.sh
emit-terminal-sequence.sh
should-use-structured.sh
warp-notify.sh
legacy/on-session-start.sh
legacy/on-stop.sh
legacy/on-notification.sh
legacy/warp-notify.sh
Fix
Replace #!/bin/bash with #!/usr/bin/env bash in all scripts:
find plugins/warp/scripts/ -name "*.sh" -exec sed -i '' 's|^#!/bin/bash|#!/usr/bin/env bash|' {} +
This ensures the user's $PATH-resolved bash is used, so $BASH_ENV is sourced by the correct version.
Related
Environment
- OS: macOS (Apple Silicon)
/bin/bash: 3.2.57
- User's bash: 5.2.37 (Homebrew)
- Claude Code: latest
- Plugin: claude-code-warp latest
Summary
All hook scripts use
#!/bin/bashas their shebang. On macOS,/bin/bashis permanently pinned to bash 3.2.57 (Apple won't ship newer versions due to GPLv3 licensing). Users who install a modern bash (4.x/5.x) via Homebrew or similar have their$PATHconfigured to use the newer version, but the hardcoded shebang bypasses$PATHentirely.When bash runs a script (non-interactive shell), it sources
$BASH_ENVif set. Because the hooks force/bin/bash3.2,$BASH_ENVgets sourced under bash 3.2 instead of the user's expected bash version. Any bash 4+ or 5+ features in the$BASH_ENVtarget file will fail or behave unexpectedly.How it breaks
/opt/homebrew/bin/bash) and$PATHprioritizes it$BASH_ENVset, pointing to a file that uses modern bash features#!/bin/bash→ launches/bin/bash(3.2.57)$BASH_ENV, and sources the file${var,,},|&,readarray,declare -g, etc.)Reproduction
Affected files
All
.shscripts underplugins/warp/scripts/andplugins/warp/scripts/legacy/:on-post-tool-use.shon-session-start.shon-prompt-submit.shon-stop.shon-permission-request.shon-notification.shbuild-payload.shemit-terminal-sequence.shshould-use-structured.shwarp-notify.shlegacy/on-session-start.shlegacy/on-stop.shlegacy/on-notification.shlegacy/warp-notify.shFix
Replace
#!/bin/bashwith#!/usr/bin/env bashin all scripts:This ensures the user's
$PATH-resolved bash is used, so$BASH_ENVis sourced by the correct version.Related
/bin/bashat all)Environment
/bin/bash: 3.2.57