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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X7GvKuJfy2WrdBmUttV4DT
This commit is contained in:
@@ -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)"
|
||||
|
||||
Reference in New Issue
Block a user