From 57ed94c4218e2a3dddc7eee4982d95dfec9ad7f4 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 9 Jun 2025 19:59:41 +0100 Subject: [PATCH] cmd/vendor-install: fix exit code handling for curl --- Library/Homebrew/cmd/vendor-install.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/vendor-install.sh b/Library/Homebrew/cmd/vendor-install.sh index 8825d9fccd..3d58dab372 100644 --- a/Library/Homebrew/cmd/vendor-install.sh +++ b/Library/Homebrew/cmd/vendor-install.sh @@ -101,6 +101,7 @@ fetch() { local first_try=1 local vendor_locations local temporary_path + local curl_exit_code=0 curl_args=() @@ -149,19 +150,27 @@ fetch() { # HOMEBREW_CURL is set by brew.sh (and isn't misspelt here) # shellcheck disable=SC2153 "${HOMEBREW_CURL}" "${curl_args[@]}" -C - "${url}" -o "${temporary_path}" - if [[ $? -eq 33 ]] + curl_exit_code="$?" + if [[ "${curl_exit_code}" -eq 33 ]] then [[ -n "${HOMEBREW_QUIET}" ]] || echo "Trying a full download" >&2 rm -f "${temporary_path}" "${HOMEBREW_CURL}" "${curl_args[@]}" "${url}" -o "${temporary_path}" + curl_exit_code="$?" fi else "${HOMEBREW_CURL}" "${curl_args[@]}" "${url}" -o "${temporary_path}" + curl_exit_code="$?" fi [[ -f "${temporary_path}" ]] && break done + if [[ "${curl_exit_code}" -ne 0 ]] + then + rm -f "${temporary_path}" + fi + if [[ ! -f "${temporary_path}" ]] then vendor_locations="$(printf " - %s\n" "${VENDOR_URLs[@]}")"