2014-11-12 20:36:15 -08:00
|
|
|
#!/usr/bin/zsh
|
2021-07-29 00:37:35 -07:00
|
|
|
# YES_ZSH
|
2021-08-02 05:17:37 -07:00
|
|
|
# YES_BASH
|
|
|
|
# YES_DASH
|
2021-09-23 06:48:05 -07:00
|
|
|
# YES_ASH
|
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 "$@"
|