1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 08:19:03 -08:00
rc/sh/isup

15 lines
322 B
Bash
Executable file

#!/usr/bin/zsh
# YES_ZSH
# NO_BASH
# NO_DASH
# TODO: damned substrings. rewrite to be semi-portable.
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 ]
}
[ "${SOURCING:-0}" -gt 0 ] || isup "$@"