gam-install.sh: check curl response code

This commit is contained in:
Jay Lee 2024-12-11 15:23:25 -08:00 committed by GitHub
parent d0b7ac80da
commit 39e5a45d72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -120,14 +120,24 @@ else
curl_opts=( "$GHCLIENT" )
fi
echo_yellow "Checking GitHub URL $release_url for $gamversion GAM release ($check_type)..."
release_json=$(curl \
release_response=$(curl \
--silent \
"${curl_opts[@]}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"$release_url" \
-w "%{http_code}" \
2>&1 /dev/null)
response_status="${release_response: -3}"
release_json="${release_response:0:-4}"
if [ "$response_status" != "200" ]; then
echo_red "ERROR when retrieving ${release_url}:\n\n${release_json}"
exit
else
echo_green "done"
fi
echo_yellow "Getting file and download URL..."
# Python is sadly the nearest to universal way to safely handle JSON with Bash
# At least this code should be compatible with just about any Python version ever