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-ASN: 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 C399D1F5A9 for ; Fri, 15 Nov 2019 09:51:01 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/29] mda: pass global variables into subs Date: Fri, 15 Nov 2019 09:50:37 +0000 Message-Id: <20191115095100.25633-7-e@80x24.org> In-Reply-To: <20191115095100.25633-1-e@80x24.org> References: <20191115095100.25633-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Avoid 'Variable "%s" will not stay shared' warnings when the contents of this script eval'ed into a sub. --- script/public-inbox-mda | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/script/public-inbox-mda b/script/public-inbox-mda index dca8a0ea..9da2d90f 100755 --- a/script/public-inbox-mda +++ b/script/public-inbox-mda @@ -9,11 +9,11 @@ my $usage = 'public-inbox-mda [OPTIONS] < rfc2822_message'; my $precheck = grep(/\A--no-precheck\z/, @ARGV) ? 0 : 1; my ($ems, $emm); -sub do_exit { +my $do_exit = sub { my ($code) = shift; $emm = $ems = undef; # trigger DESTROY exit $code; -} +}; use Email::Simple; use PublicInbox::MIME; @@ -48,7 +48,7 @@ if (!scalar(@$dests)) { if (!scalar(@$dests) && !defined($recipient)) { die "ORIGINAL_RECIPIENT not defined in ENV\n"; } - scalar(@$dests) or do_exit(67); # EX_NOUSER 5.1.1 user unknown + scalar(@$dests) or $do_exit->(67); # EX_NOUSER 5.1.1 user unknown } my $err; @@ -67,7 +67,7 @@ my $err; } } @$dests; -do_exit(67) if $err && scalar(@$dests) == 0; +$do_exit->(67) if $err && scalar(@$dests) == 0; $simple = undef; my $spam_ok; @@ -84,7 +84,7 @@ if ($spamc) { my $fh = $emm->fh; read($fh, $str, -s $fh); } -do_exit(0) unless $spam_ok; +$do_exit->(0) unless $spam_ok; # -mda defaults to the strict base filter which we won't use anywhere else sub mda_filter_adjust ($) { @@ -131,4 +131,4 @@ if (scalar(@rejects) && scalar(@rejects) == scalar(@$dests)) { die join("\n", @rejects, ''); } -do_exit(0); +$do_exit->(0);