fix: refactor script execution to use array for improved handling of numbered scripts
This commit is contained in:
11
setup.sh
11
setup.sh
@@ -24,9 +24,13 @@ 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
|
||||
# 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
|
||||
@@ -36,7 +40,6 @@ if [ -d "$DOTFILES_DIR/scripts" ]; then
|
||||
exit 1
|
||||
fi
|
||||
((script_count++))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $script_count -eq 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user