fix(install): use nullglob so cleanup doesn't trip set -e on empty install

The cleanup loop iterated over the literal "dgx-spark-*" when no existing
install was present, causing [ -L ] to fail and set -e to kill the script
before the install step. Enable nullglob so unmatched globs disappear,
and use explicit if/fi blocks instead of && for the test-then-rm pattern.
This commit is contained in:
Jason Kneen 2026-04-19 10:23:09 +01:00
parent a680d0472b
commit 3e9a50b48c

View File

@ -52,14 +52,20 @@ fi
# Clean previous installs from BOTH targets so switching modes stays clean.
cleanup_skills() {
[ -d "$SKILLS_DIR" ] || return 0
for link in "$SKILLS_DIR/dgx-spark" "$SKILLS_DIR/dgx-spark-"*; do
[ -L "$link" ] && rm "$link"
shopt -s nullglob
local links=("$SKILLS_DIR/dgx-spark" "$SKILLS_DIR/dgx-spark-"*)
shopt -u nullglob
for link in "${links[@]}"; do
if [ -L "$link" ]; then
rm "$link"
fi
done
}
cleanup_plugin() {
local link="$PLUGINS_DIR/dgx-spark-playbooks"
[ -L "$link" ] && rm "$link"
return 0
if [ -L "$link" ]; then
rm "$link"
fi
}
cleanup_skills
cleanup_plugin