]> Sergey Matveev's repositories - public-inbox.git/commitdiff
index: pass global variables into subs
authorEric Wong <e@80x24.org>
Fri, 15 Nov 2019 09:50:35 +0000 (09:50 +0000)
committerEric Wong <e@80x24.org>
Sat, 16 Nov 2019 11:05:23 +0000 (11:05 +0000)
Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

script/public-inbox-index

index 139b6e56d267bd6db455bfe2be0cd138645ee7be..102381c390510bc086897638a16596c87d859d74 100755 (executable)
@@ -18,11 +18,10 @@ GetOptions($opt, qw(verbose|v+ reindex jobs|j=i prune indexlevel|L=s))
        or die "bad command-line args\n$usage";
 die "--jobs must be positive\n" if defined $opt->{jobs} && $opt->{jobs} <= 0;
 
-sub usage { print STDERR "Usage: $usage\n"; exit 1 }
 
 my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV);
 PublicInbox::Admin::require_or_die('-index');
-usage() unless @ibxs;
+unless (@ibxs) { print STDERR "Usage: $usage\n"; exit 1 }
 my $mods = {};
 foreach my $ibx (@ibxs) {
        # XXX: users can shoot themselves in the foot, with opt->{indexlevel}