From 9c631e813f82622264f53c8ff5417c2dfacc4757 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Mon, 27 May 2013 21:18:04 -0700 Subject: [PATCH] handle curl errors, pass exit status along --- meow.sh | 10 ++++++---- run | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/meow.sh b/meow.sh index 31bd3e7..73a10a2 100644 --- a/meow.sh +++ b/meow.sh @@ -54,6 +54,7 @@ groupfilter() { # groupname regex [timestamp] groupreleases "$1" "${3:-}" | while IFS=$SEP read -r title torrent; do grep -P "$2" <<< "$title" 1>/dev/null && echo "$title$SEP$torrent" done + [ ${PIPESTATUS[0]} = 0 ] || exit 1 } cleanup() { @@ -62,13 +63,14 @@ cleanup() { echo "touchgroup $gs $v" >> times.sh [ -e "$gs.xml" ] && rm "$gs.xml" done - exit 0 + exit ${1:-1} } # TODO: optionally buffer lists so interrupting and restarting wont give the same output runall() { trap cleanup INT + ret=0 local insane regex timestamp now for gs in "${!groupshows[@]}"; do @@ -76,9 +78,9 @@ runall() { regex="${groupshows[$gs]:1}" timestamp="${grouptimes[$gs]}" now="$(date -u '+%s')" - groupfilter "$insane" "$regex" "$timestamp" - touchgroup "$gs" "$now" + ( groupfilter "$insane" "$regex" "$timestamp" ) + [ $? = 0 ] && touchgroup "$gs" "$now" || ret=1 done - cleanup + cleanup $ret } diff --git a/run b/run index 4f983ec..aecb881 100755 --- a/run +++ b/run @@ -11,3 +11,4 @@ prettify() { . config.sh [ -e times.sh ] && { . times.sh; mv times.sh times.sh.old; } runall | prettify +exit ${PIPESTATUS[0]}