refactor: extract eval_expr helper and simplify eval_expressions loop

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 18:29:35 +02:00
co-authored by Claude Sonnet 4.6
parent db3bab3558
commit 73feb5cb63
+12 -3
View File
@@ -40,6 +40,17 @@ source_file() {
fi
}
# Eval the output of a command, silently skipping if it fails or produces nothing
# Usage: eval_expr 'pyenv init -'
eval_expr() {
local cmd="$1"
local output
if output="$(eval "$cmd" 2>/dev/null)" && [[ -n "$output" ]]; then
eval "$output"
fi
}
# =============================================================================
# PATH EXTENSIONS
@@ -90,9 +101,7 @@ eval_expressions=(
)
for expr in "${eval_expressions[@]}"; do
if output="$(eval "$expr" 2>/dev/null)"; then
eval "$output"
fi
eval_expr "$expr"
done