]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
admin: autodie chdir + open
authorEric Wong <e@80x24.org>
Sat, 16 Nov 2024 07:09:51 +0000 (07:09 +0000)
committerEric Wong <e@80x24.org>
Sun, 17 Nov 2024 18:54:12 +0000 (18:54 +0000)
autodie gives us more consistent error messages and reduces
visual noise on our end.  We can also open() directly into a
hash entry without relying on a temporary variable.

lib/PublicInbox/Admin.pm

index bb5d365327e7c54697342dd2ea4b8b7d964582bb..fb745cf8eacfd1d7c2ac7009db34ee9e1155a24a 100644 (file)
@@ -6,6 +6,7 @@
 package PublicInbox::Admin;
 use v5.12;
 use parent qw(Exporter);
+use autodie qw(chdir open);
 our @EXPORT_OK = qw(setup_signals fmt_localtime);
 use PublicInbox::Config;
 use PublicInbox::Inbox;
@@ -313,9 +314,7 @@ sub progress_prepare ($;$) {
                $opt->{quiet} = !$opt->{verbose};
        }
        if ($opt->{quiet}) {
-               open my $null, '>', '/dev/null' or
-                       die "failed to open /dev/null: $!\n";
-               $opt->{1} = $null; # suitable for spawn() redirect
+               open $opt->{1}, '>', '/dev/null'; # suitable for spawn() redirect
        } else {
                $opt->{verbose} ||= 1;
                $dst //= \*STDERR;
@@ -378,7 +377,7 @@ sub do_chdir ($) {
        my $chdir = $_[0] // return;
        for my $d (@$chdir) {
                next if $d eq ''; # same as git(1)
-               chdir $d or die "cd $d: $!";
+               chdir $d;
        }
 }