diff --git a/setup.sh b/setup.sh index 5672462..fc10723 100644 --- a/setup.sh +++ b/setup.sh @@ -24,19 +24,22 @@ if [ -d "$DOTFILES_DIR/scripts" ]; then log_info "Running setup scripts..." script_count=0 - # Find and run all numbered scripts using shell globbing - for script in "$DOTFILES_DIR/scripts"/[0-9][0-9]-*; do - if [ -f "$script" ]; then - script_name=$(basename "$script") - log_info "Running $script_name..." - if bash "$script" "$DOTFILES_DIR"; then - log_success "✓ $script_name completed" - else - log_error "✗ $script_name failed" - exit 1 - fi - ((script_count++)) + # Collect numbered scripts into an array + # Enable nullglob to ensure no-match yields empty array + shopt -s nullglob + scripts=("$DOTFILES_DIR/scripts"/[0-9][0-9]-*.sh) + shopt -u nullglob + # Run each discovered script + for script in "${scripts[@]}"; do + script_name=$(basename "$script") + log_info "Running $script_name..." + if bash "$script" "$DOTFILES_DIR"; then + log_success "✓ $script_name completed" + else + log_error "✗ $script_name failed" + exit 1 fi + ((script_count++)) done if [ $script_count -eq 0 ]; then