diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-03-21 11:47:07 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-03-21 12:04:09 +0100 |
commit | 125164fc972b3149aa65db4a839224dbf24ef8aa (patch) | |
tree | 6a3bb0fd654581e5fe257260db4589630a5993bc | |
parent | 373cabcf7b96ebafc8cd544de5f08bda3e81b375 (diff) |
sfeed_update: set exit status non-zero if any of the feeds failed
In practise this may change the meaning of the examples:
sfeed_update && pkill -SIGHUP sfeed_curses
An alternative:
sfeed_update; pkill -SIGHUP sfeed_curses
-rwxr-xr-x | sfeed_update | 11 | ||||
-rw-r--r-- | sfeed_update.1 | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/sfeed_update b/sfeed_update index b5f38bc..f2c97ae 100755 --- a/sfeed_update +++ b/sfeed_update @@ -41,6 +41,8 @@ log() { # log_error(name, s) log_error() { printf '[%s] %-50.50s %s\n' "$(date +'%H:%M:%S')" "$1" "$2" >&2 + # set error exit status indicator for parallel jobs. + rm -f "${sfeedtmpdir}/ok" } # fetch a feed via HTTP/HTTPS etc. @@ -96,7 +98,7 @@ _feed() { filename="$(printf '%s' "${name}" | tr '/' '_')" sfeedfile="${sfeedpath}/${filename}" - tmpfeedfile="${sfeedtmpdir}/${filename}" + tmpfeedfile="${sfeedtmpdir}/feeds/${filename}" # if file does not exist yet create it. [ -e "${sfeedfile}" ] || touch "${sfeedfile}" 2>/dev/null @@ -201,17 +203,22 @@ main() { loadconfig "$1" # fetch feeds and store in temporary directory. sfeedtmpdir="$(mktemp -d '/tmp/sfeed_XXXXXX')" + mkdir -p "${sfeedtmpdir}/feeds" + touch "${sfeedtmpdir}/ok" # make sure path exists. mkdir -p "${sfeedpath}" # fetch feeds specified in config file. feeds # wait till all feeds are fetched (concurrently). [ ${signo} -eq 0 ] && wait + # check error exit status indicator for parallel jobs. + test -f "${sfeedtmpdir}/ok" + status=$? # cleanup temporary files etc. cleanup # on signal SIGINT and SIGTERM exit with signal number + 128. [ ${signo} -ne 0 ] && exit $((signo+128)) - return 0 + return ${status} } [ "${SFEED_UPDATE_INCLUDE}" = "1" ] || main "$@" diff --git a/sfeed_update.1 b/sfeed_update.1 index aca52de..3edf551 100644 --- a/sfeed_update.1 +++ b/sfeed_update.1 @@ -62,7 +62,6 @@ stdout in the format: .Ed .Sh EXIT STATUS .Ex -std -A (temporary) failure with processing a feed is not considered an error here. .Sh EXAMPLES To update your feeds and format them in various formats: .Bd -literal |