mirror of
https://github.com/notwa/rc
synced 2024-11-05 08:19:03 -08:00
improve isup compatiblity
This commit is contained in:
parent
d6300c4578
commit
d1095a192e
1 changed files with 4 additions and 7 deletions
11
sh/isup
11
sh/isup
|
@ -1,15 +1,12 @@
|
||||||
#!/usr/bin/zsh
|
#!/usr/bin/zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
# NO_BASH
|
# YES_BASH
|
||||||
# NO_DASH
|
# YES_DASH
|
||||||
|
|
||||||
# TODO: damned substrings. rewrite to be semi-portable.
|
|
||||||
|
|
||||||
isup() { ### @-
|
isup() { ### @-
|
||||||
### return 0 if a given website returns a 2xx HTTP code.
|
### return 0 if a given website returns a 2xx HTTP code.
|
||||||
local c
|
local c="$(curl -sLI -w '%{http_code}' -o /dev/null "$1")"
|
||||||
curl -sLI -w '%{http_code}' -o /dev/null "$1" | read -r c
|
[ -z "${c#2[0-9][0-9]}" ]
|
||||||
[ "${c:0:1}" -eq 2 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "${SOURCING:-0}" -gt 0 ] || isup "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || isup "$@"
|
||||||
|
|
Loading…
Reference in a new issue