Fix arithmetic increment bug in installer causing silent exit

((var++)) returns exit code 1 when incrementing from 0, which
triggers set -e. Added || true to all 13 arithmetic operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 17:31:57 +09:00
parent 2aa9d098cb
commit 9ba0748bf2

View File

@@ -145,18 +145,18 @@ setup_global_commands() {
local current_link local current_link
current_link=$(readlink "$target") current_link=$(readlink "$target")
if [[ "$current_link" == "$cmd_file" ]]; then if [[ "$current_link" == "$cmd_file" ]]; then
((skipped++)) ((skipped++)) || true
else else
rm "$target" rm "$target"
ln -s "$cmd_file" "$target" ln -s "$cmd_file" "$target"
((updated++)) ((updated++)) || true
fi fi
elif [[ -f "$target" ]]; then elif [[ -f "$target" ]]; then
warn "Skipping $filename (non-symlink file exists at $target)" warn "Skipping $filename (non-symlink file exists at $target)"
((skipped++)) ((skipped++)) || true
else else
ln -s "$cmd_file" "$target" ln -s "$cmd_file" "$target"
((linked++)) ((linked++)) || true
fi fi
done done
@@ -188,7 +188,7 @@ remove_global_commands() {
link_target=$(readlink "$link") link_target=$(readlink "$link")
if [[ "$link_target" == "$REPO_COMMANDS_DIR/"* ]]; then if [[ "$link_target" == "$REPO_COMMANDS_DIR/"* ]]; then
rm "$link" rm "$link"
((removed++)) ((removed++)) || true
fi fi
done done
@@ -339,24 +339,24 @@ validate_installation() {
local checks_total=7 local checks_total=7
# Check directories # Check directories
[[ -d "$CONFIG_DIR" ]] && ((checks_passed++)) && success "Config directory exists" || warn "Config directory missing" [[ -d "$CONFIG_DIR" ]] && { ((checks_passed++)) || true; success "Config directory exists"; } || warn "Config directory missing"
[[ -d "$CONFIG_DIR/credentials" ]] && ((checks_passed++)) && success "Credentials directory exists" || warn "Credentials directory missing" [[ -d "$CONFIG_DIR/credentials" ]] && { ((checks_passed++)) || true; success "Credentials directory exists"; } || warn "Credentials directory missing"
# Check files # Check files
[[ -f "$ENV_FILE" ]] && ((checks_passed++)) && success "Environment file exists" || warn "Environment file missing" [[ -f "$ENV_FILE" ]] && { ((checks_passed++)) || true; success "Environment file exists"; } || warn "Environment file missing"
[[ -f "$CONFIG_DIR/config.yaml" ]] && ((checks_passed++)) && success "Config file exists" || warn "Config file missing" [[ -f "$CONFIG_DIR/config.yaml" ]] && { ((checks_passed++)) || true; success "Config file exists"; } || warn "Config file missing"
# Check virtual environment # Check virtual environment
[[ -d "$VENV_DIR" ]] && ((checks_passed++)) && success "Virtual environment exists" || warn "Virtual environment missing" [[ -d "$VENV_DIR" ]] && { ((checks_passed++)) || true; success "Virtual environment exists"; } || warn "Virtual environment missing"
# Check skills directory # Check skills directory
[[ -d "$SKILLS_DIR/01-ourdigital-brand-guide" ]] && ((checks_passed++)) && success "Skills directory valid" || warn "Skills not found" [[ -d "$SKILLS_DIR/01-ourdigital-brand-guide" ]] && { ((checks_passed++)) || true; success "Skills directory valid"; } || warn "Skills not found"
# Check global commands # Check global commands
local cmd_count local cmd_count
cmd_count=$(find "$CLAUDE_COMMANDS_DIR" -maxdepth 1 -type l -lname "$REPO_COMMANDS_DIR/*" 2>/dev/null | wc -l | tr -d ' ') cmd_count=$(find "$CLAUDE_COMMANDS_DIR" -maxdepth 1 -type l -lname "$REPO_COMMANDS_DIR/*" 2>/dev/null | wc -l | tr -d ' ')
if [[ $cmd_count -gt 0 ]]; then if [[ $cmd_count -gt 0 ]]; then
((checks_passed++)) ((checks_passed++)) || true
success "Global slash commands installed ($cmd_count commands)" success "Global slash commands installed ($cmd_count commands)"
else else
warn "No global slash commands found (run with --commands to install)" warn "No global slash commands found (run with --commands to install)"
@@ -391,7 +391,7 @@ show_skills() {
for pattern in "${pattern_arr[@]}"; do for pattern in "${pattern_arr[@]}"; do
for dir in "$SKILLS_DIR"/$pattern; do for dir in "$SKILLS_DIR"/$pattern; do
if [[ -d "$dir" ]]; then if [[ -d "$dir" ]]; then
((count++)) ((count++)) || true
names+=("$(basename "$dir")") names+=("$(basename "$dir")")
fi fi
done done
@@ -425,7 +425,7 @@ show_global_commands() {
local link_target local link_target
link_target=$(readlink "$link") link_target=$(readlink "$link")
if [[ "$link_target" == "$REPO_COMMANDS_DIR/"* ]]; then if [[ "$link_target" == "$REPO_COMMANDS_DIR/"* ]]; then
((cmd_count++)) ((cmd_count++)) || true
local name local name
name=$(basename "$link" .md) name=$(basename "$link" .md)
categories+=("$name") categories+=("$name")
@@ -441,13 +441,13 @@ show_global_commands() {
local seo=0 gtm=0 jamie=0 notebooklm=0 notion=0 ourdigital=0 other=0 local seo=0 gtm=0 jamie=0 notebooklm=0 notion=0 ourdigital=0 other=0
for name in "${categories[@]}"; do for name in "${categories[@]}"; do
case "$name" in case "$name" in
seo-*) ((seo++)) ;; seo-*) ((seo++)) || true ;;
gtm-*) ((gtm++)) ;; gtm-*) ((gtm++)) || true ;;
jamie-*) ((jamie++)) ;; jamie-*) ((jamie++)) || true ;;
notebooklm-*) ((notebooklm++)) ;; notebooklm-*) ((notebooklm++)) || true ;;
notion-*) ((notion++)) ;; notion-*) ((notion++)) || true ;;
ourdigital-*) ((ourdigital++)) ;; ourdigital-*) ((ourdigital++)) || true ;;
*) ((other++)) ;; *) ((other++)) || true ;;
esac esac
done done