1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 02:29:06 -08:00

improve isup compatiblity

This commit is contained in:
Connor Olding 2021-08-02 05:17:37 -07:00
parent d6300c4578
commit d1095a192e

11
sh/isup
View file

@ -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 "$@"