This file is indexed.

/usr/bin/einfo is in ncbi-entrez-direct 7.40.20170928+ds-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/perl -w
# Detect whether to run einfo.epub or edirect -info.

use strict;

my $usage = <<EOF;
USAGE: einfo [<epub einfo options>] <filename>
 -or-  einfo [<NCBI Entrez Direct einfo options>]

per, respectively,

    einfo.epub -h (or man einfo.epub)
    edirect -info -help (or man einfo)
EOF

if ( !@ARGV  ||  ! -x '/usr/bin/einfo.epub' ) {
    ExecNCBI();
} elsif (grep /--?help/, @ARGV) {
    print $usage;
    exit 0;
}

my $epub_flags = 'qvdp';
my $epub_keys  = 't';

my %ncbi_supported = (
    'db'          => 's',
    'dbs'         => undef,
    'fields'      => undef,
    'links'       => undef,
    'email'       => 's',
    'tool'        => 's',
    'help'        => undef,
    'silent'      => undef,
    'verbose'     => undef,
    'debug'       => undef,
    'log'         => undef,
    'http'        => 's',
    'https'       => 's',
    'alias'       => 's',
    'base'        => 's');

my %ncbi_abbrev = ();
{
    my @names = sort keys %ncbi_supported;
    unshift @names, '';
    push @names, '';
    my $i;
    my $j;
    for ($i = 1;  $i + 1 < @names;  ++$i) {
        my $name      = $names[$i];
        my $prev_name = $names[$i - 1];
        my $next_name = $names[$i + 1];
        for ($j = 1;  $j < length($name);  ++$j) {
            my $abbrev = substr($name, 0, $j);
            if ($abbrev ne substr($prev_name, 0, $j)
                &&  $abbrev ne substr($next_name, 0, $j)) {
                $ncbi_abbrev{$abbrev} = $name;
            }
        }
    }
}

my @epub_red_flags;
my @epub_yellow_flags;
my $epub_value_expected;
my $epub_query;
my @ncbi_red_flags;
my @ncbi_yellow_flags;
my $ncbi_value_expected;

for (@ARGV) {
    if (/^-\d+$/  ||  !/^-/) {
        if ( !defined $epub_value_expected ) {
            if (defined $epub_query) {
                push @epub_red_flags, "$epub_query $_";
            }
            $epub_query = $_;
        }
        if ( !defined $ncbi_value_expected ) {
            push @ncbi_red_flags, $_;
        }
        undef $epub_value_expected;
        undef $ncbi_value_expected;
    } else {
        my $epub_type;
        if (defined $epub_value_expected) {
            push @epub_red_flags, "$epub_value_expected $_";
            $epub_type = 'nominal-value';
            undef $epub_value_expected;
        } elsif (/^-[ho]$/  ||  /^-[$epub_flags]*(?:[$epub_keys].+)?$/) {
            $epub_type = 'flag';
        } elsif (/^-[$epub_flags]*([$epub_keys])$/) {
            $epub_type = 'key';
            $epub_value_expected = "-$1";
        } else {
            $epub_type = 'invalid';
            push @epub_red_flags, $_;
        }

        my $ncbi_type;
        if (defined $ncbi_value_expected) {
            push @ncbi_red_flags, "$ncbi_value_expected $_";
            $ncbi_type = 'nominal-value';
            undef $ncbi_value_expected;
        } elsif (/^--?([^=]+)(=.*)?/) {
            my $base = lc($1);
            my $has_value = defined $2;
            if (exists $ncbi_abbrev{$base}) {
                $base = $ncbi_abbrev{$base};
                push @ncbi_yellow_flags, $_;
            }
            if ( !exists $ncbi_supported{$base}
                 ||  ($has_value  &&  !defined $ncbi_supported{$base})) {
                $ncbi_type = 'invalid';
                push @ncbi_red_flags, $_;
            } else {
                if (lc($1) eq $base  &&  $1 =~ /[A-Z]/) {
                    # Worry about capitalization only if otherwise OK
                    push @ncbi_yellow_flags, $_;
                }
                if (defined $ncbi_supported{$base}  &&  !$has_value) {
                    $ncbi_type = 'key';
                    $ncbi_value_expected = $_;
                } else {
                    $ncbi_type = 'flag';
                }
            }
        } else {
            $ncbi_type = 'invalid';
            push @ncbi_red_flags, $_;
        }

        if ($epub_type =~ /^[fk]/  &&  $ncbi_type =~ /^[fk]/) {
            # Could technically be valid for einfo.epub, but far likelier
            # to have been intended for edirect -info.
            push @epub_yellow_flags, $_;
        }
    }
}

if ( !defined $epub_query ) {
    push @epub_red_flags, "no filename";
}
if (defined $epub_value_expected) {
    push @epub_red_flags, "$epub_value_expected with no value";
}
if (defined $ncbi_value_expected) {
    push @ncbi_red_flags, "$ncbi_value_expected with no value";
}

my $epub_red  = @epub_red_flags;
my $epub_ylw  = @epub_yellow_flags;
my $ncbi_red   = @ncbi_red_flags;
my $ncbi_ylw   = @ncbi_yellow_flags;

if ($epub_red  &&  !$ncbi_red) {
    # clear-cut, even if there happen to be NCBI yellow flags
    ExecNCBI();
} elsif ($ncbi_red  &&  !$epub_red) {
    ExecEpub();
}

my $epub_misgivings = "EPUB misgivings ($epub_red major, $epub_ylw minor):";
my $ncbi_misgivings  = "NCBI misgivings ($ncbi_red major, $ncbi_ylw minor):";

for (@epub_red_flags) {
    $epub_misgivings .= "\n  $_ (major)";
}
for (@epub_yellow_flags) {
    $epub_misgivings .= "\n  $_ (minor)";
}
for (@ncbi_red_flags) {
    $ncbi_misgivings .= "\n  $_ (major)";
}
for (@ncbi_yellow_flags) {
    $ncbi_misgivings .= "\n  $_ (minor)";
}

if ($ncbi_red > $epub_red
    ||  ($ncbi_red == $epub_red  &&  $ncbi_ylw > $epub_ylw)) {
    if ($epub_red  ||  $epub_ylw) {
        warn <<EOF;
Launching EPUB einfo rather than NCBI einfo despite misgivings,
due to more severe misgivings about NCBI syntax compatibility.  If you
meant to run NCBI einfo, please explicitly run it via edirect -info.
$ncbi_misgivings
$epub_misgivings
EOF
    }
    ExecEpub();
}

if ($epub_red > $ncbi_red
    ||  ($epub_red == $ncbi_red  &&  $epub_ylw > $ncbi_ylw)) {
    if ($ncbi_red  ||  $ncbi_ylw) {
        warn <<EOF;
Launching NCBI einfo rather than EPUB einfo despite misgivings,
due to more severe misgivings about EPUB syntax compatibility.  If you
meant to run EPUB einfo, please explicitly run it via einfo.epub.
$epub_misgivings
$ncbi_misgivings
EOF
    }
    ExecNCBI();
}

if ($epub_red) {
    die <<EOF;
Usage equally bad for both EPUB einfo and NCBI einfo.  Please double
check your usage or explicitly run einfo.epub or edirect -info.
$epub_misgivings
$ncbi_misgivings

$usage
EOF
} elsif ($epub_ylw) {
    die <<EOF;
Usage equally suspect (but still technically valid, at least to first
approximation) for both EPUB einfo and NCBI einfo.  Please double
check your usage or explicitly run einfo.epub or edirect -info.
$epub_misgivings
$ncbi_misgivings

$usage
EOF
} else {
    die <<EOF;
Usage apparently valid (at least to first approximation) for both
EPUB einfo and NCBI einfo.  Please disambiguate your usage or
explicitly run einfo.epub or edirect -info.
EOF
}

sub ExecEpub
{
    # exec {'/usr/bin/einfo.epub'} ('/usr/bin/einfo', @ARGV);
    exec('/usr/bin/einfo.epub', @ARGV);
}
sub ExecNCBI
{
    exec('/usr/bin/edirect', '-info', @ARGV);
}