about summary refs log tree commit homepage
path: root/scripts
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-04-18 03:38:50 +0000
committerEric Wong <e@yhbt.net>2020-04-19 08:51:24 +0000
commita479b45117ed69d9311770fa39e6676d38f9cab2 (patch)
tree9262dbdd0147b02a7d9d9a797271ec25e8aa1c5f /scripts
parenta014723b600e35cd495f048c89611e611436a15e (diff)
downloadpublic-inbox-a479b45117ed69d9311770fa39e6676d38f9cab2.tar.gz
I did not know to use the return value of `do' back in the day.
There's probably no practical difference in these cases, but
`eval' is overkill for these uses and may hide actual errors.

We can get rid of a few redundant `scalar' ops and pass scalar
refs to Email::MIME->new to avoid copies in a few more places,
too.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/import_maildir4
-rwxr-xr-xscripts/import_slrnspool2
-rwxr-xr-xscripts/slrnspool2maildir2
-rwxr-xr-xscripts/ssoma-replay5
4 files changed, 5 insertions, 8 deletions
diff --git a/scripts/import_maildir b/scripts/import_maildir
index fbf3f649..f4e82543 100755
--- a/scripts/import_maildir
+++ b/scripts/import_maildir
@@ -28,7 +28,7 @@ my @msgs;
 foreach my $sub (qw(cur new)) {
         foreach my $fn (glob("$dir/$sub/*")) {
                 open my $fh, '<', $fn or next;
-                my $s = Email::Simple->new(eval { local $/; <$fh> });
+                my $s = Email::Simple->new(do { local $/; <$fh> });
                 my $date = $s->header('Date');
                 my $t = eval { str2time($date) };
                 defined $t or next;
@@ -45,7 +45,7 @@ my $im = PublicInbox::Import->new($git, $name, $email);
 while (my $ary = pop @msgs) {
         my $fn = "$dir/$ary->[1]";
         open my $fh, '<', $fn or next;
-        my $mime = PublicInbox::MIME->new(eval { local $/; <$fh> });
+        my $mime = PublicInbox::MIME->new(do { local $/; <$fh> });
         $im->add($mime);
 }
 $im->done;
diff --git a/scripts/import_slrnspool b/scripts/import_slrnspool
index e569d004..480e7b4f 100755
--- a/scripts/import_slrnspool
+++ b/scripts/import_slrnspool
@@ -70,7 +70,7 @@ for (; $exit == 0 && $n < $max; $n++) {
         $max = $n + $max_gap;
         print STDERR $fn, "\n";
 
-        my $mime = PublicInbox::MIME->new(eval { local $/; <$fh> });
+        my $mime = PublicInbox::MIME->new(do { local $/; <$fh> });
         $filter->scrub($mime);
         $im->add($mime);
 
diff --git a/scripts/slrnspool2maildir b/scripts/slrnspool2maildir
index 0c21806a..8e444e84 100755
--- a/scripts/slrnspool2maildir
+++ b/scripts/slrnspool2maildir
@@ -23,7 +23,7 @@ foreach my $sub (qw(cur new tmp)) {
 
 foreach my $n (grep(/\d+\z/, glob("$spool/*"))) {
         if (open my $fh, '<', $n) {
-                my $f = Email::Filter->new(data => eval { local $/; <$fh> });
+                my $f = Email::Filter->new(data => do { local $/; <$fh> });
                 my $s = $f->simple;
 
                 # gmane rewrites Received headers, which increases spamminess
diff --git a/scripts/ssoma-replay b/scripts/ssoma-replay
index 3e928084..07121423 100755
--- a/scripts/ssoma-replay
+++ b/scripts/ssoma-replay
@@ -30,10 +30,7 @@ use Email::Simple;
 use URI::Escape qw/uri_escape_utf8/;
 use File::Temp qw/tempfile/;
 my ($fh, $filename) = tempfile('ssoma-replay-XXXXXXXX', TMPDIR => 1);
-my $msg = eval {
-        local $/;
-        Email::Simple->new(<STDIN>);
-};
+my $msg = Email::Simple->new(do { local $/; <STDIN> });
 select $fh;
 
 # Note: the archive URL makes assumptions about where the