From ad1e8152772f52bf70329ff0a393f860c739c209 Mon Sep 17 00:00:00 2001 From: Samuel Henrique Date: Sat, 29 Jun 2024 12:54:33 +0100 Subject: [PATCH] Use 'exec' instead of 'eval', thanks to sergiodj --- wcurl | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/wcurl b/wcurl index bb33064..e996ae8 100755 --- a/wcurl +++ b/wcurl @@ -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