Prefer curl in download()

This commit is contained in:
2025-04-12 14:56:20 -04:00
parent 36bebb1d45
commit 9eed36d353

View File

@@ -1787,38 +1787,24 @@ execute() {
download() { download() {
local url="$1" local url="$1"
local output="${2:-}" local output="${2:-}"
local -a download_cmd local -a cmd
if command -v curl &>/dev/null; then if command -v curl &>/dev/null || install_package --silent curl; then
cmd=(curl --silent --fail --location)
if [[ -n "$output" ]]; then if [[ -n "$output" ]]; then
download_cmd=(curl --silent --location --output "$output" "$url") cmd+=(--output "$output")
else else
download_cmd=(curl --silent --location -O "$url") cmd+=(-O)
fi
elif command -v wget &>/dev/null; then
if [[ -n "$output" ]]; then
download_cmd=(wget --quiet "--output-document=$output" "$url")
else
download_cmd=(wget --quiet "$url")
fi
elif install_package --silent curl; then
if [[ -n "$output" ]]; then
download_cmd=(curl --silent --location --output "$output" "$url")
else
download_cmd=(curl --silent --location -O "$url")
fi
elif install_package --silent wget; then
if [[ -n "$output" ]]; then
download_cmd=(wget --quiet "--output-document=$output" "$url")
else
download_cmd=(wget --quiet "$url")
fi fi
elif command -v wget &>/dev/null || install_package --silent wget; then
cmd=(wget --quiet)
[[ -n "$output" ]] && cmd+=("--output-document=$output")
else else
err "Unable to install wget or curl" err "Unable to install wget or curl"
return 1 return 1
fi fi
"${download_cmd[@]}" "${cmd[@]}" "$url"
} }
# Roughly turn debugging on for pre-init # Roughly turn debugging on for pre-init