tCheck if BIB is set before trying to append - scholarref - tools for DOI and B… | |
git clone git://src.adamsgaard.dk/scholarref | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 62af61ba6bea7c4100cfdf74731841039c3bf305 | |
parent c5a1bcce2f5570ebd5cc644102ca799c9de33903 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Mon, 16 Sep 2019 12:41:53 +0200 | |
Check if BIB is set before trying to append | |
Diffstat: | |
M scholarref | 7 ++++++- | |
1 file changed, 6 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/scholarref b/scholarref | |
t@@ -1,9 +1,13 @@ | |
#!/bin/sh | |
+die() { | |
+ printf '%s\n' "$1" >&2 | |
+ exit 1 | |
+} | |
+ | |
addref=0 | |
while :; do | |
case "$1" in | |
- - | |
-a|--add) | |
addref=1 | |
;; | |
t@@ -21,6 +25,7 @@ while :; do | |
done | |
if [ "$addref" = 1 ]; then | |
+ [ -z "$BIB" ] && die 'BIB env variable not set, should point to .bib f… | |
getdoi "$@" | getref -n >> "$BIB" | |
key="$(grep '@.*{' "$BIB" | tail -n 1 | sed 's/.*{//;s/,$//')" | |
echo "Citation $key added to $BIB" |