about summary refs log tree commit homepage
path: root/script
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-11-15 09:50:32 +0000
committerEric Wong <e@80x24.org>2019-11-16 11:05:23 +0000
commit04d0b9c097cc8f6d5868c4e072710baaf870f99c (patch)
tree617c5e4dfacea73d90bc6f190be75ebebd17bcbf /script
parent4f0eed9d221a3e16da35145a17501798422f359e (diff)
downloadpublic-inbox-04d0b9c097cc8f6d5868c4e072710baaf870f99c.tar.gz
Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.
Diffstat (limited to 'script')
-rwxr-xr-xscript/public-inbox-edit17
1 files changed, 9 insertions, 8 deletions
diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index 43ce9900..c9884053 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -46,9 +46,9 @@ PublicInbox::AdminEdit::check_editable(\@ibxs);
 
 my $found = {}; # cid => [ [ibx, smsg] [, [ibx, smsg] ] ]
 
-sub find_mid ($) {
-        my ($mid) = @_;
-        foreach my $ibx (@ibxs) {
+sub find_mid ($$$) {
+        my ($found, $mid, $ibxs) = @_;
+        foreach my $ibx (@$ibxs) {
                 my $over = $ibx->over;
                 my ($id, $prev);
                 while (my $smsg = $over->next_by_mid($mid, \$id, \$prev)) {
@@ -68,7 +68,8 @@ sub show_cmd ($$) {
         " GIT_DIR=$ibx->{inboxdir}/all.git \\\n    git show $smsg->{blob}\n";
 }
 
-sub show_found () {
+sub show_found ($) {
+        my ($found) = @_;
         foreach my $to_edit (values %$found) {
                 foreach my $tuple (@$to_edit) {
                         my ($ibx, $smsg) = @$tuple;
@@ -79,7 +80,7 @@ sub show_found () {
 
 if (defined($mid)) {
         $mid = mid_clean($mid);
-        $found = find_mid($mid);
+        find_mid($found, $mid, \@ibxs);
         my $nr = scalar(keys %$found);
         die "No message found for <$mid>\n" unless $nr;
         if ($nr > 1) {
@@ -87,7 +88,7 @@ if (defined($mid)) {
 Multiple messages with different content found matching
 <$mid>:
 
-                show_found();
+                show_found($found);
                 die "Use --force to edit all of them\n" if !$opt->{force};
                 warn "Will edit all of them\n";
         }
@@ -96,7 +97,7 @@ Multiple messages with different content found matching
         my $orig = do { local $/; <$fh> };
         my $mime = PublicInbox::MIME->new(\$orig);
         my $mids = mids($mime->header_obj);
-        find_mid($_) for (@$mids); # populates $found
+        find_mid($found, $_, \@ibxs) for (@$mids); # populates $found
         my $cid = content_id($mime);
         my $to_edit = $found->{$cid};
         unless ($to_edit) {
@@ -106,7 +107,7 @@ Multiple messages with different content found matching
 $nr matches to Message-ID(s) in $file, but none matched content
 Partial matches below:
 
-                        show_found();
+                        show_found($found);
                 } elsif ($nr == 0) {
                         $mids = join('', map { "  <$_>\n" } @$mids);
                         warn <<"";