summaryrefslogtreecommitdiff
path: root/elink
diff options
context:
space:
mode:
authorAaron M. Ucko <ucko@debian.org>2020-11-01 15:07:43 -0500
committerAaron M. Ucko <ucko@debian.org>2020-11-01 15:07:43 -0500
commitb3b5834eba173ee91a23e1c7ca01138fec0e3e79 (patch)
tree4fdcb3925e185f34e20c2e4de12838debf1f353b /elink
parented0222f223cd8c5e8aed20c3ad8cb015a9d6f710 (diff)
New upstream version 14.0.20201030+dfsg
Diffstat (limited to 'elink')
-rwxr-xr-xelink84
1 files changed, 53 insertions, 31 deletions
diff --git a/elink b/elink
index ff4761f..3a625e9 100755
--- a/elink
+++ b/elink
@@ -32,31 +32,50 @@
#
# ==========================================================================
-for x in "$@"
-do
- if [ "x$x" = "x-newmode" ]
- then
- USE_NEW_EDIRECT=1
- break
- fi
-done
-
pth=$( dirname "$0" )
+# conditionally execute original Perl implementation
+
PERL=""
+internal=no
+while [ "$#" -ne 0 ]
+do
+ case "$1" in
+ -internal )
+ internal=yes
+ shift
+ ;;
+ -newmode )
+ USE_NEW_EDIRECT=1
+ shift
+ ;;
+ -oldmode )
+ USE_NEW_EDIRECT=0
+ shift
+ ;;
+ * )
+ break
+ ;;
+ esac
+done
+if [ "$internal" = yes ]
+then
+ set _ -internal "$@"
+ shift
+fi
+
if [ ! -f "$pth"/ecommon.sh ]
then
USE_NEW_EDIRECT=false
fi
-# set PERL path if using old EDirect
-
case "${USE_NEW_EDIRECT}" in
"" | [FfNn]* | 0 | [Oo][Ff][Ff] )
+ # set PERL path if using old EDirect
PERL=perl
case "$( uname -s )" in
- CYGWIN_NT*)
+ CYGWIN_NT* )
# Use a negative match here because the shell treats 0 as success.
if perl -e 'exit $^O !~ /^MSWin/'; then
pth=$( cygpath -w "$pth" )
@@ -71,8 +90,6 @@ case "${USE_NEW_EDIRECT}" in
;;
esac
-# conditionally execute original Perl implementation
-
if [ -n "${PERL}" ]
then
exec "${PERL}" "$pth"/edirect.pl -link "$@"
@@ -286,6 +303,10 @@ do
cites=true
shift
;;
+ -batch )
+ # accept -batch flag from old scripts - now standard behavior
+ shift
+ ;;
-h | -help | --help )
PrintHelp
exit 0
@@ -437,22 +458,9 @@ fi
# -cited or -cites access the NIH Open Citation Collection dataset (see PMID 31600197)
-iciteElement=""
-
-if [ "$cited" = true ]
-then
- # equivalent of -name pubmed_pubmed_citedin (for pubmed records also in pmc)
- iciteElement="cited_by"
-fi
-
-if [ "$cites" = true ]
-then
- # equivalent of -name pubmed_pubmed_refs (for pubmed records also in pmc)
- iciteElement="references"
-fi
-
LinkInIcite() {
+ iciteElement="$1"
GenerateUidList "$dbase" |
join-into-groups-of 100 |
while read uids
@@ -466,9 +474,9 @@ LinkInIcite() {
epost -db pubmed -log "$log"
}
-if [ -n "$iciteElement" ]
-then
- cits=$( LinkInIcite )
+QueryIcite() {
+
+ cits=$( LinkInIcite "$1" )
if [ -n "$cits" ]
then
@@ -478,6 +486,20 @@ then
fi
WriteEDirect "$dbase" "$web_env" "$qry_key" "$num" "$stp" "$err"
+}
+
+if [ "$cited" = true ]
+then
+ # equivalent of -name pubmed_pubmed_citedin (for pubmed records also in pmc)
+ QueryIcite "cited_by"
+
+ exit 0
+fi
+
+if [ "$cites" = true ]
+then
+ # equivalent of -name pubmed_pubmed_refs (for pubmed records also in pmc)
+ QueryIcite "references"
exit 0
fi