From 71246abc261a719b3676338ec95ec7fc70faf3b3 Mon Sep 17 00:00:00 2001 From: Sprite Date: Sat, 7 Feb 2026 05:03:02 +0000 Subject: [PATCH] Fix source detection for process substitution (bash <(curl ...)) BASH_SOURCE[0] is /proc/self/fd/N with process substitution, not "-" or "bash". Instead of guessing execution context, just check if the local lib/common.sh file actually exists. Co-Authored-By: Claude Sonnet 4.5 --- sprite/claude.sh | 9 +++------ sprite/openclaw.sh | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/sprite/claude.sh b/sprite/claude.sh index 271e89ae..360190d5 100755 --- a/sprite/claude.sh +++ b/sprite/claude.sh @@ -1,14 +1,11 @@ #!/bin/bash set -e -# Source common functions -# Check if running via curl | bash or locally -if [[ -n "${BASH_SOURCE[0]}" && "${BASH_SOURCE[0]}" != "-" && "${BASH_SOURCE[0]}" != "bash" ]]; then - # Running locally - source from local file - SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Source common functions - try local file first, fall back to remote +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)" +if [[ -f "$SCRIPT_DIR/lib/common.sh" ]]; then source "$SCRIPT_DIR/lib/common.sh" else - # Running via curl | bash - download from GitHub source <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/sprite/lib/common.sh) fi diff --git a/sprite/openclaw.sh b/sprite/openclaw.sh index bb29cc82..3aba373a 100755 --- a/sprite/openclaw.sh +++ b/sprite/openclaw.sh @@ -1,14 +1,11 @@ #!/bin/bash set -e -# Source common functions -# Check if running via curl | bash or locally -if [[ -n "${BASH_SOURCE[0]}" && "${BASH_SOURCE[0]}" != "-" && "${BASH_SOURCE[0]}" != "bash" ]]; then - # Running locally - source from local file - SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Source common functions - try local file first, fall back to remote +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)" +if [[ -f "$SCRIPT_DIR/lib/common.sh" ]]; then source "$SCRIPT_DIR/lib/common.sh" else - # Running via curl | bash - download from GitHub source <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/sprite/lib/common.sh) fi