Merge pull request #364 from davemorin/fix/361-unsafe-eval-check-config

fix(hooks): replace unsafe eval with declare in check-config.sh
This commit is contained in:
Trevin Chow
2026-05-17 00:02:44 -07:00
committed by GitHub
+6 -1
View File
@@ -33,8 +33,13 @@ load_env_vars() {
[[ -z "$key" ]] && continue [[ -z "$key" ]] && continue
key=$(echo "$key" | xargs) key=$(echo "$key" | xargs)
value=$(echo "$value" | xargs | sed 's/^["'\''"]//;s/["'\''"]$//') value=$(echo "$value" | xargs | sed 's/^["'\''"]//;s/["'\''"]$//')
# Strip inline comments (# preceded by whitespace) to prevent
# command substitution in backtick-containing comments
value="${value%%[[:space:]]#*}"
if [[ -n "$key" && -n "$value" ]]; then if [[ -n "$key" && -n "$value" ]]; then
eval "ENV_${key}=\"${value}\"" # printf -v writes via assignment semantics (global from inside a
# function), works on macOS's /bin/bash 3.2 — `declare -g` is 4.2+.
printf -v "ENV_${key}" '%s' "$value"
fi fi
done < "$file" done < "$file"
fi fi