diff options
Diffstat (limited to 'hyperterm/core')
-rw-r--r-- | hyperterm/core/update.sh | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/hyperterm/core/update.sh b/hyperterm/core/update.sh index 841780f..03e3608 100644 --- a/hyperterm/core/update.sh +++ b/hyperterm/core/update.sh @@ -10,32 +10,20 @@ function _which() { # Check URL's # --------------------- function _url_exists() { - if _which wget; then - if wget --spider "$1" 2>/dev/null; then - return 0 # URL 'ok' - else - return 1 # URL 'fail' - fi - elif _which curl; then - if curl --output /dev/null --silent --head --fail "$1"; then - return 0 # URL 'ok' - else - return 1 # URL 'fail' - fi - fi + curl --output /dev/null 2>&1 -s -w "%{http_code}\n" "$1" } function _urls() { URL_1="https://c.hgit.ga/software/hyperterm.git" URL_2="https://git.sr.ht/~heckyel/hyperterm" - - if [[ $(_url_exists "$URL_1") -eq 0 ]]; then - URL="$URL_1" - RAW="$URL_1/plain" - elif [[ $(_url_exists "$URL_2") -eq 0 ]]; then - URL="$URL_2" - RAW="$URL_2/blob/master" - fi + case $(_url_exists "$URL_1") in + 200) URL="$URL_1" + RAW="$URL_1/plain";; + esac + case $(_url_exists "$URL_2") in + 200) URL="$URL_2" + RAW="$URL_2/blob/master";; + esac } # ---------------------- |