From 9218fe512cbfbf41103e45306a849b9b01b1cd26 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Tue, 5 May 2026 23:33:03 +0200 Subject: [PATCH] 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. --- install.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index bf43cb3..24e9672 100755 --- a/install.sh +++ b/install.sh @@ -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}"