Skip to content

Commit

Permalink
Add support for sha256sum command
Browse files Browse the repository at this point in the history
  • Loading branch information
yann-soubeyrand committed Apr 3, 2020
1 parent 45a8ad7 commit aac4751
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libexec/tfenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ esac;

keybase_bin="$(command -v keybase 2>/dev/null)";
shasum_bin="$(command -v shasum 2>/dev/null)";
sha256sum_bin="$(command -v sha256sum 2>/dev/null)";

TFENV_REMOTE="${TFENV_REMOTE:-https://releases.hashicorp.com}";
version_url="${TFENV_REMOTE}/terraform/${version}";
Expand Down Expand Up @@ -226,6 +227,13 @@ if [[ -n "${shasum_bin}" && -x "${shasum_bin}" ]]; then
-c <(grep -F "${tarball_name}" "${shasums_name}") \
|| log 'error' 'SHA256 hash does not match!';
);
elif [[ -n "${sha256sum_bin}" && -x "${sha256sum_bin}" ]]; then
(
cd "${download_tmp}";
"${sha256sum_bin}" \
-c <(grep -F "${tarball_name}" "${shasums_name}") \
|| log 'error' 'SHA256 hash does not match!';
);
else
# Lack of shasum deserves a proper warning
log 'warn' 'No shasum tool available. Skipping SHA256 hash validation';
Expand Down

0 comments on commit aac4751

Please sign in to comment.