From 2c1bf79c67d6072617bb13ea1960e76ef69a1194 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 4 Jun 2024 13:49:32 +0100 Subject: [PATCH] cmd/vendor-install: handle broken `shasum`. If `shasum` is broken and doesn't produce a valid checksum: we were just doing the checksum comparison with an empty checksum. Instead, let's treat an empty checksum as a failure condition, rather than just the executable bit being present for the relevant binary, and iterate through the available tools to try and get a non-empty checksum. If they all produce an empty checksum: provide a different error to make it a bit more obvious what's happening here. --- Library/Homebrew/cmd/vendor-install.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cmd/vendor-install.sh b/Library/Homebrew/cmd/vendor-install.sh index 695a538c03..d173754175 100644 --- a/Library/Homebrew/cmd/vendor-install.sh +++ b/Library/Homebrew/cmd/vendor-install.sh @@ -186,21 +186,33 @@ EOS if [[ -x "/usr/bin/shasum" ]] then sha="$(/usr/bin/shasum -a 256 "${CACHED_LOCATION}" | cut -d' ' -f1)" - elif [[ -x "$(type -P sha256sum)" ]] + fi + + if [[ -z "${sha}" && -x "$(type -P sha256sum)" ]] then sha="$(sha256sum "${CACHED_LOCATION}" | cut -d' ' -f1)" - elif [[ -x "$(type -P ruby)" ]] + fi + + if [[ -z "${sha}" ]] then - sha="$( - ruby <