better error handling

This commit is contained in:
Connor Olding 2014-03-15 14:32:44 -07:00
parent 465cb743c8
commit aff9ef3b18
2 changed files with 16 additions and 10 deletions

21
meow.sh
View File

@ -71,14 +71,19 @@ runfilter() { # {action} [database]
done < "$mark"
now="$(date +%s)"
for regex in "${searchregex[@]}"; do
while IFS=$SEP read -r time tid title; do
[ -n "${already[$tid]}" ] \
|| $action $time $tid "$title" \
|| break
already[$tid]="$now"
done < <(searchfilter "$db" "${regex:1}")
done
while IFS=$SEP read -r time tid title; do
[ -n "${already[$tid]}" ] \
|| $action $time $tid "$title" \
|| {
echo "[meow.sh] failed to run $action" >&2
echo "[meow.sh] torrent title: $title" >&2
echo "[meow.sh] torrent id: $tid" >&2
break
}
already[$tid]="$now"
done < <(for regex in "${searchregex[@]}"; do
searchfilter "$db" "${regex:1}"
done)
rm "$mark"
for tid in "${!already[@]}"; do

5
run
View File

@ -4,11 +4,12 @@ SRCDIR="$(readlink -f "$(dirname "$0")" )"
# TODO: a way to pass opts to transmission-remote
declare -a actions
while getopts 'aph' opt; do
while getopts 'ap' opt; do
case $opt in
a) actions+=(addtorrent);;
p) actions+=(prettify);;
?) echo -E "usage: $0 [-ap]" 1>&2;;
?) echo -E "usage: $0 [-ap]" >&2
return 1;;
esac
done