From: Eric Wong Date: Mon, 22 Dec 2025 20:16:23 +0000 (+0000) Subject: doc/common: rely on autodie + wrappers to detect errors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=HEAD;p=thirdparty%2Fpublic-inbox.git doc/common: rely on autodie + wrappers to detect errors common.perl already depends on PublicInbox::Search, so it's fine to also depend on autodie and PublicInbox::IO for error checking. The only place autodie isn't acceptable is probably Makefile.PL, since some RH-based distros package it independently of Perl. --- diff --git a/Documentation/common.perl b/Documentation/common.perl index 98a06ee1..c56223bf 100755 --- a/Documentation/common.perl +++ b/Documentation/common.perl @@ -1,14 +1,15 @@ #!perl -w # Copyright (C) all contributors # License: AGPL-3.0+ -use strict; -use autodie qw(seek); +use v5.12; +use autodie qw(close open seek truncate); use Fcntl qw(SEEK_SET); use PublicInbox::Search; +use PublicInbox::IO qw(read_all); my $addr = 'meta@public-inbox.org'; for my $pod (@ARGV) { - open my $fh, '+<', $pod or die "open($pod): $!"; - my $s = do { local $/; <$fh> } // die "read $!"; + open my $fh, '+<', $pod; + my $s = read_all $fh; my $orig = $s; $s =~ s!^=head1 COPYRIGHT\n.+?^=head1([^\n]+)\n!=head1 COPYRIGHT @@ -40,9 +41,9 @@ L utime($t, $t, $fh); } else { seek $fh, 0, SEEK_SET; - truncate($fh, 0) or die "truncate: $!"; - print $fh $s or die "print: $!"; - close $fh or die "close: $!"; + truncate $fh, 0; + print $fh $s; + close $fh; } }