From 0e7c19e686487eec490178ef0e3f32c66699120c Mon Sep 17 00:00:00 2001 From: Don Luchini Date: Tue, 30 May 2023 09:11:12 -0400 Subject: [PATCH] Do not check the release list if a Terraform is already installed (fixes #395) Today, tfenv checks the Terraform release list when running `tfenv install`, even if the requested Terraform is already installed. This fixes an issue where a script containing `tfenv install` becomes inoperable even if Terraform is installed, but releases.hashicorp.com is down. See #395 for more information. --- libexec/tfenv-install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libexec/tfenv-install b/libexec/tfenv-install index d13b384..d298118 100755 --- a/libexec/tfenv-install +++ b/libexec/tfenv-install @@ -73,15 +73,15 @@ declare regex="${resolved##*\:}"; log 'debug' "Processing install for version ${version}, using regex ${regex}"; -remote_version="$(tfenv-list-remote | grep -e "${regex}" | head -n 1)"; -[ -n "${remote_version}" ] && version="${remote_version}" || log 'error' "No versions matching '${requested:-$version}' found in remote"; - dst_path="${TFENV_CONFIG_DIR}/versions/${version}"; if [ -f "${dst_path}/terraform" ]; then echo "Terraform v${version} is already installed"; exit 0; fi; +remote_version="$(tfenv-list-remote | grep -e "${regex}" | head -n 1)"; +[ -n "${remote_version}" ] && version="${remote_version}" || log 'error' "No versions matching '${requested:-$version}' found in remote"; + case "$(uname -s)" in Darwin*) kernel="darwin";