handle curl errors, pass exit status along

This commit is contained in:
Connor Olding 2013-05-27 21:18:04 -07:00
parent 95d0b230e2
commit 9c631e813f
2 changed files with 7 additions and 4 deletions

10
meow.sh
View File

@ -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
}

1
run
View File

@ -11,3 +11,4 @@ prettify() {
. config.sh
[ -e times.sh ] && { . times.sh; mv times.sh times.sh.old; }
runall | prettify
exit ${PIPESTATUS[0]}