From 8c1e021e387365d3ad50ffec3e0f54114c122940 Mon Sep 17 00:00:00 2001 From: Samuel Henrique Date: Sat, 29 Jun 2024 13:15:20 +0100 Subject: [PATCH] Only set '--parallel' if there's more than one URL Setting '--parallel' can stop other arguments from working (if the user provided something through -p/--opts). For example, '--progress-bar' doesn't work when '--parallel' is set. --- wcurl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/wcurl b/wcurl index e996ae8..d3d79f2 100755 --- a/wcurl +++ b/wcurl @@ -66,12 +66,22 @@ 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_exec_init="curl --parallel" +# Only set '--parallel' if there's more than one URL. This increases the +# compatibility with other parameters that can be passed through -o/--opts +# since some might not work together with --parallel. +if (( ${#urls_to_download[@]} > 1 )); then + declare -r command_to_exec_init="curl --parallel" +else + declare -r command_to_exec_init="curl" +fi + 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 -" + +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 +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_exec" == "$command_to_exec_init" ]]; then