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:
+16
-8
@@ -88,25 +88,33 @@ EOF
|
|||||||
done
|
done
|
||||||
|
|
||||||
# ── build install set ─────────────────────────────────
|
# ── build install set ─────────────────────────────────
|
||||||
# Populates INSTALL_SET associative array: keys are bare names (no .ts suffix).
|
# INSTALL_SET: space-delimited bare names (no .ts suffix). Bash 3 compatible.
|
||||||
declare -A INSTALL_SET
|
INSTALL_SET=""
|
||||||
|
|
||||||
|
in_install_set() { [[ " $INSTALL_SET " == *" $1 "* ]]; }
|
||||||
|
|
||||||
build_install_set() {
|
build_install_set() {
|
||||||
|
local n f bare entry new
|
||||||
if [[ -n "$ONLY" ]]; then
|
if [[ -n "$ONLY" ]]; then
|
||||||
# Explicit allowlist — only install what's named
|
# Explicit allowlist — only install what's named
|
||||||
IFS=',' read -ra names <<< "$ONLY"
|
IFS=',' read -ra names <<< "$ONLY"
|
||||||
for n in "${names[@]}"; do
|
for n in "${names[@]}"; do
|
||||||
INSTALL_SET["${n%.ts}"]=1
|
INSTALL_SET="${INSTALL_SET:+$INSTALL_SET }${n%.ts}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
# Start with everything present on disk, then remove --skip entries
|
# Start with everything present on disk, then remove --skip entries
|
||||||
for f in "${EXTENSIONS_SRC}"/*.ts; do
|
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
|
done
|
||||||
if [[ -n "$SKIP" ]]; then
|
if [[ -n "$SKIP" ]]; then
|
||||||
IFS=',' read -ra names <<< "$SKIP"
|
IFS=',' read -ra names <<< "$SKIP"
|
||||||
for n in "${names[@]}"; do
|
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
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -122,13 +130,13 @@ do_install() {
|
|||||||
require_pi_installed
|
require_pi_installed
|
||||||
build_install_set
|
build_install_set
|
||||||
|
|
||||||
if [[ ${#INSTALL_SET[@]} -eq 0 ]]; then
|
if [[ -z "$INSTALL_SET" ]]; then
|
||||||
warn "No extensions selected — nothing to install."
|
warn "No extensions selected — nothing to install."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "==> Extensions to symlink into ${EXTENSIONS_DEST}/:"
|
echo "==> Extensions to symlink into ${EXTENSIONS_DEST}/:"
|
||||||
for n in "${!INSTALL_SET[@]}"; do
|
for n in $INSTALL_SET; do
|
||||||
printf ' %s.ts\n' "$n"
|
printf ' %s.ts\n' "$n"
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
@@ -140,7 +148,7 @@ do_install() {
|
|||||||
local name
|
local name
|
||||||
name="$(basename "$src")"
|
name="$(basename "$src")"
|
||||||
local bare="${name%.ts}"
|
local bare="${name%.ts}"
|
||||||
[[ -n "${INSTALL_SET[$bare]:-}" ]] || continue
|
in_install_set "$bare" || continue
|
||||||
|
|
||||||
local dest="${EXTENSIONS_DEST}/${name}"
|
local dest="${EXTENSIONS_DEST}/${name}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user