about summary refs log tree commit homepage
path: root/script/public-inbox-init
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-27 02:53:05 +0000
committerEric Wong <e@80x24.org>2020-12-28 23:19:48 +0000
commit522bb4a4973d4ac41b83be58dd3257e8cd038744 (patch)
tree4ff707e12c1520ac6c8b80249bde1be4ee76250e /script/public-inbox-init
parent0f545dd95ca88e69f011aa56d07494887e7df822 (diff)
downloadpublic-inbox-522bb4a4973d4ac41b83be58dd3257e8cd038744.tar.gz
Reading from regular files (even on STDIN) can fail
when dealing with flakey storage.
Diffstat (limited to 'script/public-inbox-init')
-rwxr-xr-xscript/public-inbox-init6
1 files changed, 1 insertions, 5 deletions
diff --git a/script/public-inbox-init b/script/public-inbox-init
index 6d538e43..7ac77830 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -100,11 +100,7 @@ if (-e $pi_config) {
         defined $perm or die "(f)stat failed on $pi_config: $!\n";
         chmod($perm & 07777, $fh) or
                 die "(f)chmod failed on future $pi_config: $!\n";
-        my $old;
-        {
-                local $/;
-                $old = <$oh>;
-        }
+        defined(my $old = do { local $/; <$oh> }) or die "read $pi_config: $!\n";
         print $fh $old or die "failed to write: $!\n";
         close $oh or die "failed to close $pi_config: $!\n";