Skip to content

Commit 020a5dc

Browse files
committed
ensure correct exit when offline (#32)
without an internet connection, the script will: - `exit` if sourced - `return` if copied and pasted Signed-off-by: Lucas Larson <LucasLarson@riseup.net>
1 parent 1a6da7f commit 020a5dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

update

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env sh
2-
update='2023-07-16'
2+
update='2023-10-04'
33
IFS="$(command printf -- ' \t\n|')" && IFS="${IFS%'|'}"
44
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
55
command printf -- '\360\237\223\241 verifying network connectivity' >&2
@@ -15,7 +15,7 @@ command printf -- '\n\n' >&2
1515
{ command ping -c 1 -- one.one.one.one >/dev/null 2>&1 && command ping -c 1 -- 9.9.9.9 >/dev/null 2>&1; } || {
1616
update="${?-}"
1717
command printf -- 'No internet connection detected.\nAborting update.\n' >&2
18-
return "${update:-1}"
18+
case "${SHELL##*/}" in *"${0##*-}") return "${update:-1}";; *) exit "${update:-1}";; esac
1919
}
2020
set -- 'https://lucaslarson.net/update'
2121
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')" || {

0 commit comments

Comments
 (0)