fix: refactor script discovery to use shell globbing for improved performance
This commit is contained in:
18
setup.sh
18
setup.sh
@@ -24,19 +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 log all numbered scripts using shell globbing
|
||||||
# Find all numbered scripts and run them in order (robust while-read loop)
|
for script in "$DOTFILES_DIR/scripts"/[0-9][0-9]-*; do
|
||||||
while IFS= read -r script; do
|
if [ -f "$script" ]; then
|
||||||
script_name=$(basename "$script")
|
script_name=$(basename "$script")
|
||||||
log_info "Running $script_name..."
|
log_info "Found script: $script_name"
|
||||||
if bash "$script"; then
|
|
||||||
log_success "✓ $script_name completed"
|
|
||||||
else
|
|
||||||
log_error "✗ $script_name failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
((script_count++))
|
done
|
||||||
done < <(find "$DOTFILES_DIR/scripts" -name '[0-9][0-9]-*.sh' -type f | sort)
|
|
||||||
|
|
||||||
if [ $script_count -eq 0 ]; then
|
if [ $script_count -eq 0 ]; then
|
||||||
log_warning "No numbered scripts found in scripts/ directory"
|
log_warning "No numbered scripts found in scripts/ directory"
|
||||||
|
|||||||
Reference in New Issue
Block a user