fix(install): replace declare -A with bash 3 compatible string set

macOS ships bash 3.2 which does not support associative arrays (declare -A,
bash 4+ only). Replace INSTALL_SET associative array with a space-delimited
string and an in_install_set() helper function. All operations preserved:
add, skip/remove, empty-check, iteration, membership test.
This commit is contained in:
2026-05-05 23:33:03 +02:00
parent b29bf6db2d
commit 9218fe512c
+16 -8
View File
@@ -88,25 +88,33 @@ EOF
done
# ── build install set ─────────────────────────────────
# Populates INSTALL_SET associative array: keys are bare names (no .ts suffix).
declare -A INSTALL_SET
# INSTALL_SET: space-delimited bare names (no .ts suffix). Bash 3 compatible.
INSTALL_SET=""
in_install_set() { [[ " $INSTALL_SET " == *" $1 "* ]]; }
build_install_set() {
local n f bare entry new
if [[ -n "$ONLY" ]]; then
# Explicit allowlist — only install what's named
IFS=',' read -ra names <<< "$ONLY"
for n in "${names[@]}"; do
INSTALL_SET["${n%.ts}"]=1
INSTALL_SET="${INSTALL_SET:+$INSTALL_SET }${n%.ts}"
done
else
# Start with everything present on disk, then remove --skip entries
for f in "${EXTENSIONS_SRC}"/*.ts; do
[[ -e "$f" ]] && INSTALL_SET["$(basename "$f" .ts)"]=1
[[ -e "$f" ]] && INSTALL_SET="${INSTALL_SET:+$INSTALL_SET }$(basename "$f" .ts)"
done
if [[ -n "$SKIP" ]]; then
IFS=',' read -ra names <<< "$SKIP"
for n in "${names[@]}"; do
unset "INSTALL_SET[${n%.ts}]" 2>/dev/null || true
bare="${n%.ts}"
new=""
for entry in $INSTALL_SET; do
[[ "$entry" == "$bare" ]] || new="${new:+$new }$entry"
done
INSTALL_SET="$new"
done
fi
fi
@@ -122,13 +130,13 @@ do_install() {
require_pi_installed
build_install_set
if [[ ${#INSTALL_SET[@]} -eq 0 ]]; then
if [[ -z "$INSTALL_SET" ]]; then
warn "No extensions selected — nothing to install."
exit 0
fi
echo "==> Extensions to symlink into ${EXTENSIONS_DEST}/:"
for n in "${!INSTALL_SET[@]}"; do
for n in $INSTALL_SET; do
printf ' %s.ts\n' "$n"
done
echo
@@ -140,7 +148,7 @@ do_install() {
local name
name="$(basename "$src")"
local bare="${name%.ts}"
[[ -n "${INSTALL_SET[$bare]:-}" ]] || continue
in_install_set "$bare" || continue
local dest="${EXTENSIONS_DEST}/${name}"