1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-12-21 21:49:40 -08:00
rc/sh/isup

17 lines
463 B
Bash
Executable file

#!/usr/bin/env sh
# compat: +ash +bash +dash +hush -ksh +mksh +oksh +osh +posh +yash +zsh
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
### ```
local c="$(curl -sLI -w '%{http_code}' -o /dev/null "$1")"
[ -z "${c#2[0-9][0-9]}" ]
}
[ -n "${preload+-}" ] || isup "$@"