Files
claude-skills/scripts/install.sh
vitya 074cbe9065 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>
2026-04-28 20:41:11 +03:00

41 lines
1.0 KiB
Bash

#!/usr/bin/env bash
# Install skills/<name>/ into ~/.claude/skills/<name>/ (or $CLAUDE_SKILLS_DIR)
# Usage: install.sh [name...] (no args = all)
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SRC="$ROOT/skills"
TARGET="${CLAUDE_SKILLS_DIR:-$HOME/.claude/skills}"
if [ "$#" -eq 0 ]; then
# 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
mkdir -p "$TARGET"
for name in "${names[@]}"; do
src_dir="$SRC/$name"
dst_dir="$TARGET/$name"
if [ ! -d "$src_dir" ]; then
echo "skip: $name (not found in skills/)" >&2
continue
fi
if [ ! -f "$src_dir/SKILL.md" ]; then
echo "skip: $name (missing SKILL.md)" >&2
continue
fi
rm -rf "$dst_dir"
cp -R "$src_dir" "$dst_dir"
echo "installed: $name$dst_dir"
done