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 authored and Zordrak committed May 27, 2020
1 parent dd83817 commit 44831e1
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 @@ -105,6 +105,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 @@ -229,6 +230,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 44831e1

Please sign in to comment.