This commit is contained in:
Alexandre
2025-07-08 11:28:33 +02:00
committed by GitHub
parent 54e7b890e6
commit 852be20e2f

View File

@@ -31,14 +31,17 @@ mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}")
sanitize_variable() { sanitize_variable() {
local raw="$1" # original value local raw="$1" # original value
local escaped # value after printf %q local escaped # value after printf %q
# Check if the value is an array
if [[ "$raw" == \[* ]]; then
echo "One of your options is an array, skipping"
return
fi
printf -v escaped '%q' "$raw" printf -v escaped '%q' "$raw"
# If nothing changed, return the original. # If nothing changed, return the original.
[[ "$raw" == "$escaped" ]] && { if [[ "$raw" == "$escaped" ]]; then
printf '%s' "$raw" printf '%s' "$raw"
return return
} fi
# Otherwise protect the escaped string with double quotes. # Otherwise protect the escaped string with double quotes.
printf '"%s"' "$escaped" printf '"%s"' "$escaped"
} }
@@ -52,7 +55,6 @@ for KEYS in "${arr[@]}"; do
else else
# Sanitize variable # Sanitize variable
VALUE=$(sanitize_variable "$VALUE") VALUE=$(sanitize_variable "$VALUE")
# Continue for single values # Continue for single values
line="${KEYS}=${VALUE}" line="${KEYS}=${VALUE}"
# Check if secret # Check if secret