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,9 +24,13 @@ if [ -d "$DOTFILES_DIR/scripts" ]; then
log_info "Running setup scripts..." log_info "Running setup scripts..."
script_count=0 script_count=0
# Find and run all numbered scripts using shell globbing # Collect numbered scripts into an array
for script in "$DOTFILES_DIR/scripts"/[0-9][0-9]-*; do # Enable nullglob to ensure no-match yields empty array
if [ -f "$script" ]; then 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") script_name=$(basename "$script")
log_info "Running $script_name..." log_info "Running $script_name..."
if bash "$script" "$DOTFILES_DIR"; then if bash "$script" "$DOTFILES_DIR"; then
@@ -36,7 +40,6 @@ if [ -d "$DOTFILES_DIR/scripts" ]; then
exit 1 exit 1
fi fi
((script_count++)) ((script_count++))
fi
done done
if [ $script_count -eq 0 ]; then if [ $script_count -eq 0 ]; then