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.
This commit is contained in:
Samuel Henrique 2024-06-29 13:15:20 +01:00
parent ad1e815277
commit 8c1e021e38

16
wcurl
View file

@ -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