Comment 1 for bug 1329872

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I can confirm that this can be a problem and is still a problem in 3.3 - 3.11.

If I setup a process to generate a list of bibs the differ from the last export to feed into the script, but I don't check to make sure that the list isn't empty then I'll accidentally send an --all dump.

It seems like --all and --pipe are just to validate other arguments, they are not used to see if ids haven't been passed.

The code that looks like it checks for ids, doesn't validate that zero IDs haven't been passed. Or that ctrl+d hasn't just been pressed.

# Look for passed in ids:
my @ids = ();
if ($config->need_ids()) {
    print STDERR "Waiting for input\n" if (-t);
    while (my $i = <>) {
        push @ids, $i if ($i =~ /^\s*[0-9]+\s*$/);
    }
}

There needs to be second check after that, to error out if no IDs were passed. Like.

die "IDs required but not entered, exiting\n" if ($config->need_ids() && !@ids);

Before that change, these commands give the same result.

echo bob | marc_export
and
marc_export --all
and
echo bob | marc_export --pipe

After
$ echo bob | marc_export
IDs required but not entered, exiting

$ echo bob | marc_export --pipe
IDs required but not entered, exiting

Josh