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:
@@ -40,6 +40,17 @@ source_file() {
|
|||||||
fi
|
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
|
# PATH EXTENSIONS
|
||||||
@@ -90,9 +101,7 @@ eval_expressions=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
for expr in "${eval_expressions[@]}"; do
|
for expr in "${eval_expressions[@]}"; do
|
||||||
if output="$(eval "$expr" 2>/dev/null)"; then
|
eval_expr "$expr"
|
||||||
eval "$output"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user