From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6B76D1F4CC for ; Sat, 16 Nov 2024 07:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1731740994; bh=Z3iq37iUgjbd7FIH+fmoGHCsSYkLMBU9gn7dR332r6s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wiptZgvV6A6J+hbsamqUHWHD3LqmLSE8JV7JJHw+BOOSFbokWIz0uSG+95uKgEPqb LKDG4KV5dSLIUFu6wAVeycW8lJ1K90A461rKoFlY0xAMJV5kD0pDtuSmC0vl9HFibJ 7U25m3OX7/uM8ABx3pmX6fKtsnvO+UDKnqynLb0Q= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/6] admin: autodie chdir + open Date: Sat, 16 Nov 2024 07:09:51 +0000 Message-ID: <20241116070953.2945078-5-e@80x24.org> In-Reply-To: <20241116070953.2945078-1-e@80x24.org> References: <20241116070953.2945078-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm index bb5d3653..fb745cf8 100644 --- a/lib/PublicInbox/Admin.pm +++ b/lib/PublicInbox/Admin.pm @@ -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; } }