]> Sergey Matveev's repositories - public-inbox.git/commitdiff
convert: check ARGV more correctly
authorEric Wong <e@yhbt.net>
Mon, 10 Aug 2020 02:12:04 +0000 (02:12 +0000)
committerEric Wong <e@yhbt.net>
Mon, 10 Aug 2020 06:26:25 +0000 (06:26 +0000)
Instead of silently ignoring excessive args, don't let a user
specify an extra directory.  Furthermore, we'll support the odd
case where BOFH wants to name an $INBOX_DIR to be `0' :P

script/public-inbox-convert

index c9075207ea4a21e86435b87e95ca5e208e591c6f..275857fad4c8864c74ff95f69bbeb6d620eb2e5a 100755 (executable)
@@ -45,8 +45,9 @@ GetOptions($opt, qw(jobs|j=i index! help|?),
 bad command-line args\n$usage
 EOF
 if ($opt->{help}) { print $help; exit 0 };
-my $old_dir = shift(@ARGV) or die $usage;
-my $new_dir = shift(@ARGV) or die $usage;
+my $old_dir = shift(@ARGV) // '';
+my $new_dir = shift(@ARGV) // '';
+die $usage if (scalar(@ARGV) || $new_dir eq '' || $old_dir eq '');
 die "$new_dir exists\n" if -d $new_dir;
 die "$old_dir not a directory\n" unless -d $old_dir;