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 17F6C1FA52 for ; Tue, 17 Oct 2023 23:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1697585900; bh=7RI0hlU0okvS/KYjqFnIdMoskffpRsaho3BVOk2KVRw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dwbLJZeL6+6glDdkJ42FNXBOqDagvJI3p1RdbwztPGcOMyD17g1ay/T1ZL3H57nbe 59zWXpHTFPESYC7B/wuKucL681fIH4TD25yxMSVvqvI+FenMe+0LnSNmDeFO7jqYnX PuIWrWIzZOQinu/O1xJDJW3dJO5N/9U9l+w7KX5A= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 23/30] init: use autodie to reduce distractions Date: Tue, 17 Oct 2023 23:38:08 +0000 Message-ID: <20231017233815.1637932-24-e@80x24.org> In-Reply-To: <20231017233815.1637932-1-e@80x24.org> References: <20231017233815.1637932-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This hurts startup time a bit, but our tests use run_script by default and I don't think normal users call -init enough to care. --- script/public-inbox-init | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/script/public-inbox-init b/script/public-inbox-init index b3e94faf..6420db7e 100755 --- a/script/public-inbox-init +++ b/script/public-inbox-init @@ -4,6 +4,7 @@ use strict; use v5.10.1; use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/; +use autodie qw(open chmod close rename); use Fcntl qw(:DEFAULT); my $help = <{indexlevel} if $ibx; } my $pi_config_tmp = $fh->filename; -close($fh) or die "failed to close $pi_config_tmp: $!\n"; +close($fh); my $pfx = "publicinbox.$name"; my @x = (qw/git config/, "--file=$pi_config_tmp"); @@ -216,8 +214,8 @@ $ibx->init_inbox(0, $skip_epoch, $skip_artnum); my $f = "$inboxdir/description"; if (sysopen $fh, $f, O_CREAT|O_EXCL|O_WRONLY) { - print $fh "public inbox for $address[0]\n" or die "print($f): $!"; - close $fh or die "close($f): $!"; + print $fh "public inbox for $address[0]\n"; + close $fh; } # needed for git prior to v2.1.0 @@ -248,9 +246,6 @@ for my $kv (@c_extra) { } # needed for git prior to v2.1.0 -chmod($perm & 07777, $pi_config_tmp) or - die "(f)chmod failed on future $pi_config: $!\n"; - -rename $pi_config_tmp, $pi_config or - die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n"; +chmod($perm & 07777, $pi_config_tmp); +rename $pi_config_tmp, $pi_config; undef $auto_unlink; # trigger ->DESTROY