diff --git a/sdoi.sh b/sdoi.sh
index 4fc15ab..37f3b48 100755
--- a/sdoi.sh
+++ b/sdoi.sh
@@ -26,25 +26,7 @@ doi=$1
fn=$2
set -e #exit if an error
-
-uid=$(curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=$doi&field=doi&retmode=xml" | grep -E "[0-9]+" | sed -E "s|([0-9]+)|\1|")
-
-tmpBib=$(mktemp -p --suffix=.bib)
-
-if [ -z "$uid" ]; then
- fetchBib_doiDotOrg
-else
- fetchBib_pubmed
-fi
-
-if [ -s "$tmpBib" ]; then
- import_bib
-else
- echo "sorry, doi not found.."
- clean_up
-fi
-
-
+# set -v -x -e #debugging
function import_bib {
#decide whether to process and move an associated pdf or just exit
@@ -111,3 +93,21 @@ function clean_up {
exit 1
}
+
+uid=$(curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=$doi&field=doi&retmode=xml" | grep -E "[0-9]+" | sed -E "s|([0-9]+)|\1|")
+
+tmpBib=$(mktemp -p ./ --suffix=.bib)
+
+if [ -z "$uid" ]; then
+ fetchBib_doiDotOrg
+else
+ fetchBib_pubmed
+fi
+
+if [ -s "$tmpBib" ]; then
+ import_bib
+else
+ echo "sorry, doi not found.."
+ clean_up
+fi
+
diff --git a/spubmed.sh b/spubmed.sh
index 4d9cd20..2a68313 100755
--- a/spubmed.sh
+++ b/spubmed.sh
@@ -30,7 +30,8 @@ year=$3
set -e #exit if an error
-uid=$(curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=$author[au]+AND+$journal[ta]+AND+$year[dp]&retmode=xml" | grep -E "[0-9]+" | sed -E "s#([0-9]+)#\1#")
+#curl's option globoff needed for using brackets in a uri
+uid=$(curl -s --globoff "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=$author[au]+AND+$journal[ta]+AND+$year[dp]&retmode=xml" | grep -E "[0-9]+" | sed -E "s#([0-9]+)#\1#")
if [ -z "$uid" ]; then
echo "pubmed id not found"