better error handling
This commit is contained in:
parent
465cb743c8
commit
aff9ef3b18
21
meow.sh
21
meow.sh
|
@ -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
5
run
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue