fix: streamline script execution by removing unnecessary array handling
This commit is contained in:
28
setup.sh
28
setup.sh
@@ -24,22 +24,20 @@ if [ -d "$DOTFILES_DIR/scripts" ]; then
|
||||
log_info "Running setup scripts..."
|
||||
|
||||
script_count=0
|
||||
# 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
|
||||
# Find and run all numbered scripts using shell globbing
|
||||
for script in "$DOTFILES_DIR/scripts"/[0-9][0-9]-*.sh; do
|
||||
if [ -f "$script" ]; then
|
||||
script_name=$(basename "$script")
|
||||
log_info "Running $script_name..."
|
||||
# Source the script to run in the current shell and receive $DOTFILES_DIR as $1
|
||||
if source "$script" "$DOTFILES_DIR"; then
|
||||
log_success "✓ $script_name completed"
|
||||
else
|
||||
log_error "✗ $script_name failed"
|
||||
exit 1
|
||||
fi
|
||||
((script_count++))
|
||||
fi
|
||||
((script_count++))
|
||||
done
|
||||
|
||||
if [ $script_count -eq 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user