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:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user