1
0

fix: refactor script execution to use array for improved handling of numbered scripts

This commit is contained in:
2025-08-04 23:04:57 -05:00
parent abc38ce54c
commit 2069e46f96

View File

@@ -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