fix: streamline script execution by removing unnecessary array handling
This commit is contained in:
14
setup.sh
14
setup.sh
@@ -24,22 +24,20 @@ if [ -d "$DOTFILES_DIR/scripts" ]; then
|
|||||||
log_info "Running setup scripts..."
|
log_info "Running setup scripts..."
|
||||||
|
|
||||||
script_count=0
|
script_count=0
|
||||||
# Collect numbered scripts into an array
|
# Find and run all numbered scripts using shell globbing
|
||||||
# Enable nullglob to ensure no-match yields empty array
|
for script in "$DOTFILES_DIR/scripts"/[0-9][0-9]-*.sh; do
|
||||||
shopt -s nullglob
|
if [ -f "$script" ]; then
|
||||||
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
|
# 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"
|
log_success "✓ $script_name completed"
|
||||||
else
|
else
|
||||||
log_error "✗ $script_name failed"
|
log_error "✗ $script_name failed"
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user