From: Jacob Bachmeyer Date: Wed, 23 Nov 2022 03:38:50 +0000 (-0600) Subject: Preserve error string during rename checks at initialization X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1511d38bacae4f83c806169e78f51fdb4140bda7;p=gatekeeper.git Preserve error string during rename checks at initialization The test file is unlinked if a rename call fails; this could reset $! to indicate success, so the initial value of $! is saved first. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index 81a6e1b..3921bab 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -685,8 +685,9 @@ BEGIN { or abort "FATAL: create test file in inbox: $!"; close $test; unless (rename $infile, $scratchfile and -f $scratchfile) { + my $err = "$!"; unlink $infile; - abort "FATAL: could not rename file from inbox to scratchpad: $!"; + abort "FATAL: could not rename file from inbox to scratchpad: $err"; } unlink $scratchfile; # test complete } @@ -699,12 +700,14 @@ BEGIN { or abort "FATAL: create test file in staging directory: $!"; close $test; unless (rename $stagefile, $pubfile and -f $pubfile) { + my $err = "$!"; unlink $stagefile; - abort "FATAL: could not rename file from staging to public: $!"; + abort "FATAL: could not rename file from staging to public: $err"; } unless (rename $pubfile, $arcfile and -f $arcfile) { + my $err = "$!"; unlink $pubfile; - abort "FATAL: could not rename file from public to archive: $!"; + abort "FATAL: could not rename file from public to archive: $err"; } unlink $arcfile; # test complete }