1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-12 16:59:02 -08:00
rc/sh/isup

18 lines
427 B
Text
Raw Normal View History

2021-09-24 19:58:19 -07:00
#!/usr/bin/env sh
# YES_ZSH YES_BASH YES_DASH 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.
###
### ```
### $ 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
[ -n "${preload+-}" ] || isup "$@"