From d1095a192e452bf2bac7cbb9dec47e69b9477aff Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Mon, 2 Aug 2021 05:17:37 -0700 Subject: [PATCH] improve isup compatiblity --- sh/isup | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sh/isup b/sh/isup index cfcbb1d..a05a230 100755 --- a/sh/isup +++ b/sh/isup @@ -1,15 +1,12 @@ #!/usr/bin/zsh # YES_ZSH -# NO_BASH -# NO_DASH - -# TODO: damned substrings. rewrite to be semi-portable. +# YES_BASH +# YES_DASH isup() { ### @- ### return 0 if a given website returns a 2xx HTTP code. - local c - curl -sLI -w '%{http_code}' -o /dev/null "$1" | read -r c - [ "${c:0:1}" -eq 2 ] + local c="$(curl -sLI -w '%{http_code}' -o /dev/null "$1")" + [ -z "${c#2[0-9][0-9]}" ] } [ "${SOURCING:-0}" -gt 0 ] || isup "$@"