summaryrefslogtreecommitdiff
path: root/help2man.html.PL
diff options
context:
space:
mode:
authorBrendan O'Dea <bod@debian.org>2012-04-08 23:15:02 +1000
committerBrendan O'Dea <bod@debian.org>2012-04-08 23:15:02 +1000
commit4efbcca2dc796a5f9bf2797905fc9e6bee6a6afc (patch)
tree91ef921b5b2eaa1eac72c55415dec0d1d83a15cc /help2man.html.PL
parentc9e0d0dfa0d7afd08269c929ed27ee9587bc55f0 (diff)
downloadhelp2man-4efbcca2dc796a5f9bf2797905fc9e6bee6a6afc.tar.gz
Modify self-extracting scripts to output to a temporary file
Ensure that help2man exists before building manual pages
Diffstat (limited to 'help2man.html.PL')
-rwxr-xr-xhelp2man.html.PL19
1 files changed, 11 insertions, 8 deletions
diff --git a/help2man.html.PL b/help2man.html.PL
index 79e276c..d15bb0b 100755
--- a/help2man.html.PL
+++ b/help2man.html.PL
@@ -60,29 +60,32 @@ for ($body)
# Write output
my $target = $0;
-my $out;
+my $tmp;
if ($opts{stdout})
{
- $out = \*STDOUT;
+ *OUT = *STDOUT;
$opts{quiet} = 1;
}
else
{
$target =~ s!.*/!!;
- $target =~ s/\.PL$// or die "$0: can't determine target name\n";
- unlink $target or die "$0: can't unlink $target ($!)\n"
- if -e $target;
- open $out, ">$target" or die "$0: can't create $target ($!)\n";
+ $target =~ s/\.PL$// or die "$0: can't determine target name\n";
+ $tmp = "$target.tmp$$";
+ unlink $tmp or die "$0: can't unlink $tmp ($!)\n" if -e $tmp;
+ open OUT, ">$tmp" or die "$0: can't create $tmp ($!)\n";
}
print "Extracting $target (with GNU boilerplate)\n"
unless $opts{quiet};
-print $out $header, $body, $footer;
+print OUT $header, $body, $footer;
# Fix output file permissions
unless ($opts{stdout})
{
- close $out;
+ close OUT;
+ rename $tmp, $target or die "$0: can't rename $tmp to $target ($!)\n";
chmod 0444, $target or warn "$0: can't change mode of $target ($!)\n";
}
+
+exit 0;