From b44c1de16bcf5c44e6b1ce607f9a90d72c28e442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Tue, 28 Dec 2021 22:03:15 -0500 Subject: [update.sh]: refactory --- hyperterm/core/update.sh | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'hyperterm/core/update.sh') 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 } # ---------------------- -- cgit v1.2.3