Skip to content

Commit

Permalink
Improve curl error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Dec 25, 2022
1 parent 75aa36e commit 7cb6381
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions install_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ echo "os=$os"
echo -e "\n\n===================================================="

get_latest_release() {
curl --silent "https://api.github.com/repos/terraform-linters/tflint/releases/latest" | # Get latest release from GitHub api
curl --fail -sS "https://api.github.com/repos/terraform-linters/tflint/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
Expand All @@ -52,14 +52,8 @@ else
fi

echo "Downloading TFLint $version"
curl --fail --silent -L -o "${download_zip}" "https://github.com/terraform-linters/tflint/releases/download/${version}/tflint_${os}.zip"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to download tflint_${os}.zip"
exit $retVal
else
echo "Downloaded successfully"
fi
curl --fail -sS -L -o "${download_zip}" "https://github.com/terraform-linters/tflint/releases/download/${version}/tflint_${os}.zip"
echo "Downloaded successfully"

echo -e "\n\n===================================================="
echo "Unpacking ${download_zip} ..."
Expand Down

0 comments on commit 7cb6381

Please sign in to comment.