From 0ff694cfbd0c57c828cf7edfcd3ad561fd572f52 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Thu, 4 May 2023 13:20:16 +0200 Subject: [PATCH] produce_repeat_args_array: @mhoffrog was right, we need to quote repeat params; (here I'm being stubborn and only quoting the ones that have spaces in them) --- lib/functions/main/start-end.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/functions/main/start-end.sh b/lib/functions/main/start-end.sh index 55991d5bc8..8ba54d34cd 100644 --- a/lib/functions/main/start-end.sh +++ b/lib/functions/main/start-end.sh @@ -145,8 +145,14 @@ function produce_repeat_args_array() { # get the sorted keys of the repeat_params associative array into an array declare -a repeat_params_keys_sorted=($(printf '%s\0' "${!repeat_params[@]}" | sort -z | xargs -0 -n 1 printf '%s\n')) - for param_name in "${repeat_params_keys_sorted[@]}"; do # add sorted repeat_params to repeat_args - repeat_args+=("${param_name}=${repeat_params[${param_name}]}") # could add @Q here, but it's not necessary + for param_name in "${repeat_params_keys_sorted[@]}"; do # add sorted repeat_params to repeat_args + declare repeat_value="${repeat_params[${param_name}]}" + # does it contain spaces? if so, quote it. + if [[ "${repeat_value}" =~ [[:space:]] ]]; then + repeat_args+=("${param_name}=${repeat_value@Q}") # quote + else + repeat_args+=("${param_name}=${repeat_value}") + fi done return 0