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 groupreleases "$1" "${3:-}" | while IFS=$SEP read -r title torrent; do
grep -P "$2" <<< "$title" 1>/dev/null && echo "$title$SEP$torrent" grep -P "$2" <<< "$title" 1>/dev/null && echo "$title$SEP$torrent"
done done
[ ${PIPESTATUS[0]} = 0 ] || exit 1
} }
cleanup() { cleanup() {
@ -62,13 +63,14 @@ cleanup() {
echo "touchgroup $gs $v" >> times.sh echo "touchgroup $gs $v" >> times.sh
[ -e "$gs.xml" ] && rm "$gs.xml" [ -e "$gs.xml" ] && rm "$gs.xml"
done done
exit 0 exit ${1:-1}
} }
# TODO: optionally buffer lists so interrupting and restarting wont give the same output # TODO: optionally buffer lists so interrupting and restarting wont give the same output
runall() { runall() {
trap cleanup INT trap cleanup INT
ret=0
local insane regex timestamp now local insane regex timestamp now
for gs in "${!groupshows[@]}"; do for gs in "${!groupshows[@]}"; do
@ -76,9 +78,9 @@ runall() {
regex="${groupshows[$gs]:1}" regex="${groupshows[$gs]:1}"
timestamp="${grouptimes[$gs]}" timestamp="${grouptimes[$gs]}"
now="$(date -u '+%s')" now="$(date -u '+%s')"
groupfilter "$insane" "$regex" "$timestamp" ( groupfilter "$insane" "$regex" "$timestamp" )
touchgroup "$gs" "$now" [ $? = 0 ] && touchgroup "$gs" "$now" || ret=1
done done
cleanup cleanup $ret
} }

1
run
View File

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