From b7315424e1c21ddcc280490117e63e01087a7769 Mon Sep 17 00:00:00 2001 From: ryancnelson Date: Sun, 12 Oct 2025 10:21:15 -0700 Subject: [PATCH] Fix session-start hook: handle BASH_SOURCE unbound variable and empty grep results The hook was failing with 'Plugin hook error:' on startup due to two issues: 1. BASH_SOURCE[0] is unbound when the script is executed in certain contexts (like Claude Code plugin execution), causing failure with set -u Fix: Use /bin/bash to fallback to $0 2. When filtering status flags, grep returns exit code 1 when all lines are filtered out, causing script to exit with set -e Fix: Add '|| true' to allow empty result without failing These changes allow the hook to run successfully in all execution contexts. --- hooks/session-start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/session-start.sh b/hooks/session-start.sh index 72ab7c3d4..1b540ac71 100755 --- a/hooks/session-start.sh +++ b/hooks/session-start.sh @@ -7,7 +7,7 @@ set -euo pipefail export SUPERPOWERS_SKILLS_ROOT="${HOME}/.config/superpowers/skills" # Run skills initialization script (handles clone/fetch/auto-update) -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" init_output=$("${PLUGIN_ROOT}/lib/initialize-skills.sh" 2>&1 || echo "") @@ -15,7 +15,7 @@ init_output=$("${PLUGIN_ROOT}/lib/initialize-skills.sh" 2>&1 || echo "") skills_updated=$(echo "$init_output" | grep "SKILLS_UPDATED=true" || echo "") skills_behind=$(echo "$init_output" | grep "SKILLS_BEHIND=true" || echo "") # Remove status flags from display output -init_output=$(echo "$init_output" | grep -v "SKILLS_UPDATED=true" | grep -v "SKILLS_BEHIND=true") +init_output=$(echo "$init_output" | grep -v "SKILLS_UPDATED=true" | grep -v "SKILLS_BEHIND=true" || true) # Run find-skills to show all available skills find_skills_output=$("${SUPERPOWERS_SKILLS_ROOT}/skills/using-skills/find-skills" 2>&1 || echo "Error running find-skills")