From 3b4ccf7170e10e56d2f471c67ef555937ca3f7ed Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 6 Nov 2025 18:52:06 +0100 Subject: [PATCH] Improve env_vars export handling --- .templates/00-global_var.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.templates/00-global_var.sh b/.templates/00-global_var.sh index c43cef108..1228ca814 100755 --- a/.templates/00-global_var.sh +++ b/.templates/00-global_var.sh @@ -112,9 +112,23 @@ for KEYS in "${arr[@]}"; do env_processed=false for entry in "${env_entries[@]}"; do if [[ "$entry" == \{* ]]; then - mapfile -t env_keys < <(jq -r 'keys[]' <<<"$entry") - for env_key in "${env_keys[@]}"; do - env_value=$(jq -r --arg key "$env_key" '.[$key]' <<<"$entry") + env_name=$(jq -r 'if has("name") and has("value") then .name else empty end' <<<"$entry") + if [[ -n "$env_name" ]]; then + env_value=$(jq -r '.value // empty' <<<"$entry") + export_option "$env_name" "$env_value" + env_processed=true + continue + fi + + mapfile -t env_pairs < <(jq -r 'to_entries[] | [ .key, (.value // "") ] | @tsv' <<<"$entry") + for env_pair in "${env_pairs[@]}"; do + if [[ "$env_pair" == *$'\t'* ]]; then + env_key=${env_pair%%$'\t'*} + env_value=${env_pair#*$'\t'} + else + env_key="$env_pair" + env_value="" + fi export_option "$env_key" "$env_value" env_processed=true done