Use 'exec' instead of 'eval', thanks to sergiodj

This commit is contained in:
Samuel Henrique 2024-06-29 12:54:33 +01:00
parent 2deb288fbb
commit ad1e815277

15
wcurl
View file

@ -66,24 +66,21 @@ done
# being appended to the command is the first one or not. That's because once we
# are appending any URLs after the first one, we need to also make use of the
# "--next" parameter.
declare -r command_to_eval_init="curl --parallel"
command_to_eval="$command_to_eval_init"
declare -r command_to_exec_init="curl --parallel"
command_to_exec="$command_to_exec_init"
declare -r per_url_parameters="--location --remote-name --remote-time --retry 10 --retry-max-time 10 $curl_opts --continue-at -"
# If we have URLs to download.
if (( ${#urls_to_download[@]} != 0 )); then
for url in "${urls_to_download[@]}"; do
# If this is the first command we've added, don't prepend "--next" to it.
if [[ "$command_to_eval" == "$command_to_eval_init" ]]; then
command_to_eval="$command_to_eval $per_url_parameters $url"
if [[ "$command_to_exec" == "$command_to_exec_init" ]]; then
command_to_exec="$command_to_exec $per_url_parameters $url"
else
command_to_eval="$command_to_eval --next $per_url_parameters $url"
command_to_exec="$command_to_exec --next $per_url_parameters $url"
fi
done
fi
# Print command_to_eval if the debug environment variable is set.
[[ -z "${WCURL_DEBUG}" ]] || echo "$command_to_eval"
# Call curl with the generated parameters.
eval "$command_to_eval"
exec $command_to_exec