fix(scripts): make install.sh / build.sh work on stock macOS
Stock macOS ships bash 3.2 (frozen 2007 due to GPLv3) and BSD find. Both scripts used `mapfile` (bash 4+) and `find -printf` (GNU only), so a fresh Mac user running `bash scripts/install.sh` died on line 11 before copying anything. Replace with a portable shell glob — same sort order, no `find` dependency, works on bash 3.2 and 4+. Verified on git-bash: 16 skills discovered, install dry-run copies all, `build.sh` produces a valid archive. See .wiki/concepts/install-portability.md for the full gotcha. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,15 @@ DIST="$ROOT/dist"
|
||||
if command -v zip >/dev/null 2>&1; then
|
||||
mkdir -p "$DIST"
|
||||
if [ "$#" -eq 0 ]; then
|
||||
mapfile -t names < <(find "$SRC" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort)
|
||||
# Portable across bash 3.2 (stock macOS) and bash 4+ (Linux, git-bash):
|
||||
# avoid `mapfile` (bash 4+) and `find -printf` (GNU find only).
|
||||
names=()
|
||||
for d in "$SRC"/*/; do
|
||||
[ -d "$d" ] || continue
|
||||
names+=("$(basename "$d")")
|
||||
done
|
||||
IFS=$'\n' names=($(printf '%s\n' "${names[@]}" | sort))
|
||||
unset IFS
|
||||
else
|
||||
names=("$@")
|
||||
fi
|
||||
|
||||
@@ -8,7 +8,15 @@ SRC="$ROOT/skills"
|
||||
TARGET="${CLAUDE_SKILLS_DIR:-$HOME/.claude/skills}"
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
mapfile -t names < <(find "$SRC" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort)
|
||||
# Portable across bash 3.2 (stock macOS) and bash 4+ (Linux, git-bash):
|
||||
# avoid `mapfile` (bash 4+) and `find -printf` (GNU find only).
|
||||
names=()
|
||||
for d in "$SRC"/*/; do
|
||||
[ -d "$d" ] || continue
|
||||
names+=("$(basename "$d")")
|
||||
done
|
||||
IFS=$'\n' names=($(printf '%s\n' "${names[@]}" | sort))
|
||||
unset IFS
|
||||
else
|
||||
names=("$@")
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user