2021-09-24 19:58:19 -07:00
|
|
|
#!/usr/bin/env sh
|
2024-07-22 05:28:58 -07:00
|
|
|
# compat: +ash +bash +dash +zsh
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-07-30 17:57:08 -07:00
|
|
|
isup() { ### @-
|
|
|
|
### return 0 if a given website returns a 2xx HTTP code.
|
2021-08-02 06:06:13 -07:00
|
|
|
###
|
|
|
|
### ```
|
|
|
|
### $ isup google.com && echo yay || echo nay
|
|
|
|
### yay
|
|
|
|
### $ isup fdhafdslkjgfjs.com && echo yay || echo nay
|
|
|
|
### nay
|
|
|
|
### ```
|
2021-08-02 05:17:37 -07:00
|
|
|
local c="$(curl -sLI -w '%{http_code}' -o /dev/null "$1")"
|
|
|
|
[ -z "${c#2[0-9][0-9]}" ]
|
2014-11-12 20:36:15 -08:00
|
|
|
}
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
[ -n "${preload+-}" ] || isup "$@"
|