From b0b1470f2cd1e480600c25cb8035d23a3001fef1 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Thu, 13 Aug 2026 21:29:18 +0000 Subject: [PATCH] fix(kyberforge): guard unguarded array expansions in sync-plugin-content.sh force_flag and plugin_dirs expanded unguarded under set -euo pipefail, tripping "unbound variable" on bash 3.2 (macOS) whenever the array is empty -- which is the default --check invocation wired into the pre-commit drift gate. Apply the same ${arr[@]+"${arr[@]}"} guard already used for seen_names in this file. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01X7GvKuJfy2WrdBmUttV4DT --- scripts/sync-plugin-content.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/sync-plugin-content.sh b/scripts/sync-plugin-content.sh index f54e477..6949ae5 100755 --- a/scripts/sync-plugin-content.sh +++ b/scripts/sync-plugin-content.sh @@ -116,7 +116,7 @@ fi # silently share (and corrupt) the same $name.log/$name.status/$name.checkcopy # scratch paths below. declare -a seen_names=() -for plugin_dir in "${plugin_dirs[@]}"; do +for plugin_dir in ${plugin_dirs[@]+"${plugin_dirs[@]}"}; do name="$(basename "${plugin_dir%/}")" for seen in ${seen_names[@]+"${seen_names[@]}"}; do if [[ "$seen" == "$name" ]]; then @@ -242,7 +242,7 @@ sync_one() { cp -a "$plugin_dir/." "$pack_cwd/" fi - if ! (cd "$pack_cwd" && apm pack --format plugin "${force_flag[@]}" -o "$scratch") >"$pack_log" 2>&1; then + if ! (cd "$pack_cwd" && apm pack --format plugin "${force_flag[@]+"${force_flag[@]}"}" -o "$scratch") >"$pack_log" 2>&1; then echo "FAIL $plugin_dir: apm pack failed:" >&2 sed 's/^/ /' "$pack_log" >&2 rm -f "$pack_log" @@ -284,7 +284,7 @@ sync_one() { # on macOS. JOBS_LIMIT="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)" running=0 -for plugin_dir in "${plugin_dirs[@]}"; do +for plugin_dir in ${plugin_dirs[@]+"${plugin_dirs[@]}"}; do name="$(basename "${plugin_dir%/}")" (sync_one "$plugin_dir" "$SCRATCH_ROOT/$name.status") >"$SCRATCH_ROOT/$name.log" 2>&1 & running=$((running + 1)) @@ -295,7 +295,7 @@ for plugin_dir in "${plugin_dirs[@]}"; do done wait -for plugin_dir in "${plugin_dirs[@]}"; do +for plugin_dir in ${plugin_dirs[@]+"${plugin_dirs[@]}"}; do name="$(basename "${plugin_dir%/}")" cat "$SCRATCH_ROOT/$name.log" >&2 status="$(cat "$SCRATCH_ROOT/$name.status" 2>/dev/null || echo 1)"