commit 3c8a4fcf6a07273a25d2fcc1b38bbdfcff0b3019
parent 2830a699c32a69a417079786b3c41b0254fa5ec9
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 14 Aug 2019 11:05:22 +0200
Fix return status and fail if no result is found
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/.local/bin/getref b/.local/bin/getref
@@ -1,4 +1,5 @@
#!/bin/sh
+set -e
version=1.0
host="https://doi.org"
@@ -100,6 +101,7 @@ get_citation() {
result=$($prefix curl --location \
--header "Accept: application/x-bibtex" \
--silent --show-error "$url")
+ echo "$result" | grep -q '<html>' && die 'no result found'
result="$(echo "$result" | format_bibtex_key)"
[ "$fulljournal" = 0 ] && result="$(echo "$result" | abbreviate_journal_name)"
[ "$fullauthor" = 0 ] && result="$(echo "$result" | abbreviate_author_name)"
@@ -110,6 +112,7 @@ get_citation() {
echo "$result"
fi
[ "$notify" = 1 ] && notify-send "${0##*/}" "added: $(echo "$result" | cut -c-80)"
+ printf ''
}
verbose=0