From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C5E7D1FB05 for ; Mon, 10 Aug 2020 02:12:07 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 13/14] convert: check ARGV more correctly Date: Mon, 10 Aug 2020 02:12:04 +0000 Message-Id: <20200810021205.18909-14-e@yhbt.net> In-Reply-To: <20200810021205.18909-1-e@yhbt.net> References: <20200810021205.18909-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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;