URI:
       tCheck if BIB is set before trying to append - scholarref - tools for DOI and BiBTeX reference extraction, fetching, and parsing
  HTML git clone git://src.adamsgaard.dk/scholarref
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 62af61ba6bea7c4100cfdf74731841039c3bf305
   DIR parent c5a1bcce2f5570ebd5cc644102ca799c9de33903
  HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
       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(-)
       ---
   DIR 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 file'
                getdoi "$@" | getref -n >> "$BIB"
                key="$(grep '@.*{' "$BIB" | tail -n 1 | sed 's/.*{//;s/,$//')"
                echo "Citation $key added to $BIB"