cask-switch-https: improved getting cask_status
This commit is contained in:
parent
eb36411322
commit
4c77c208d9
|
@ -66,7 +66,7 @@ check_url_for_https() {
|
|||
|
||||
# check if the URL sends a 200 HTTP code, else abort
|
||||
browser_headers="User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36"
|
||||
cask_status=$(curl --silent ${verbose_option}--head --max-time 10 --proto =https --location --header "${browser_headers}" "${cask_url}")
|
||||
cask_status=$(curl --silent ${verbose_option} --head --max-time 10 --proto =https --location --header "${browser_headers}" --write-out '%{http_code}' "${cask_url}" -o '/dev/null')
|
||||
exit_code=$?
|
||||
|
||||
if [[ exit_code -ne 0 ]]; then
|
||||
|
@ -74,8 +74,6 @@ check_url_for_https() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
cask_status=$(echo ${cask_status} | grep '^HTTP' | tail -1 | perl -pe 's|.* (\d{3}) .*|\1|')
|
||||
|
||||
if [[ "${cask_status}" != '200' ]]; then
|
||||
if [[ -z "${cask_status}" ]]; then
|
||||
echo "URL ${cask_url} is not reachable!"
|
||||
|
|
Loading…
Reference in New Issue