Skip to content

Commit

Permalink
ensure correct exit when offline (#32)
Browse files Browse the repository at this point in the history
without an internet connection, the script will:
- `exit` if sourced
- `return` if copied and pasted

Signed-off-by: Lucas Larson <LucasLarson@riseup.net>
  • Loading branch information
LucasLarson committed Oct 5, 2023
1 parent 1a6da7f commit 020a5dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions update
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
update='2023-07-16'
update='2023-10-04'
IFS="$(command printf -- ' \t\n|')" && IFS="${IFS%'|'}"
command printf -- '\n\n .___ __\n __ ________ __\174 _\057____ _\057 \174_ ____\n\174 \174 \134____ \134 \057 __ \174\134__ \134\134 __\134\057 __ \134\n\174 \174 \057 \174_\076 \076 \057_\057 \174 \057 __ \134\174 \174 \134 ___\057\n\174____\057\174 __\057\134____ \174\050____ \057__\174 \134___ \076\n \174__\174 \134\057 \134\057 \134\057\n a Lucas Larson production\n\n' >&2 && command sleep 1
command printf -- '\360\237\223\241 verifying network connectivity' >&2
Expand All @@ -15,7 +15,7 @@ command printf -- '\n\n' >&2
{ command ping -c 1 -- one.one.one.one >/dev/null 2>&1 && command ping -c 1 -- 9.9.9.9 >/dev/null 2>&1; } || {
update="${?-}"
command printf -- 'No internet connection detected.\nAborting update.\n' >&2
return "${update:-1}"
case "${SHELL##*/}" in *"${0##*-}") return "${update:-1}";; *) exit "${update:-1}";; esac
}
set -- 'https://lucaslarson.net/update'
command test "$({ command wget --output-document=- --quiet -- "${1-}" || command curl --location --silent -- "${1-}"; } 2>/dev/null | command sed -n -e '/update=/ {' -e 's/[^[:digit:]]//gp' -e 'q' -e '}')" -le "$(command printf -- '%s\n' "${update-}" | command sed -e 's/[^[:digit:]]//g')" || {
Expand Down

0 comments on commit 020a5dc

Please sign in to comment.