better error handling
This commit is contained in:
parent
465cb743c8
commit
aff9ef3b18
13
meow.sh
13
meow.sh
|
@ -71,14 +71,19 @@ runfilter() { # {action} [database]
|
||||||
done < "$mark"
|
done < "$mark"
|
||||||
|
|
||||||
now="$(date +%s)"
|
now="$(date +%s)"
|
||||||
for regex in "${searchregex[@]}"; do
|
|
||||||
while IFS=$SEP read -r time tid title; do
|
while IFS=$SEP read -r time tid title; do
|
||||||
[ -n "${already[$tid]}" ] \
|
[ -n "${already[$tid]}" ] \
|
||||||
|| $action $time $tid "$title" \
|
|| $action $time $tid "$title" \
|
||||||
|| break
|
|| {
|
||||||
|
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"
|
already[$tid]="$now"
|
||||||
done < <(searchfilter "$db" "${regex:1}")
|
done < <(for regex in "${searchregex[@]}"; do
|
||||||
done
|
searchfilter "$db" "${regex:1}"
|
||||||
|
done)
|
||||||
|
|
||||||
rm "$mark"
|
rm "$mark"
|
||||||
for tid in "${!already[@]}"; do
|
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
|
# TODO: a way to pass opts to transmission-remote
|
||||||
|
|
||||||
declare -a actions
|
declare -a actions
|
||||||
while getopts 'aph' opt; do
|
while getopts 'ap' opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
a) actions+=(addtorrent);;
|
a) actions+=(addtorrent);;
|
||||||
p) actions+=(prettify);;
|
p) actions+=(prettify);;
|
||||||
?) echo -E "usage: $0 [-ap]" 1>&2;;
|
?) echo -E "usage: $0 [-ap]" >&2
|
||||||
|
return 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user