From: Eric Wong Date: Mon, 10 Aug 2020 02:12:04 +0000 (+0000) Subject: convert: check ARGV more correctly X-Git-Tag: v1.6.0~146 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=555b33881e340bb65808eaf3f2d334f08b0c6246 convert: check ARGV more correctly 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 --- diff --git a/script/public-inbox-convert b/script/public-inbox-convert index c9075207..275857fa 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -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;