From: P. J. McDermott Date: Sun, 22 Sep 2013 21:39:34 +0000 (-0400) Subject: Write to a temporary file. X-Git-Tag: ssic/1.0.0~29 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=4044ca6ad9ed9a23b873036b1225e2d424fa7031;p=ssic.git Write to a temporary file. --- diff --git a/src/ssic.pl b/src/ssic.pl index 5cc04ef..285c20f 100644 --- a/src/ssic.pl +++ b/src/ssic.pl @@ -127,8 +127,8 @@ sub compile if ($output eq "-") { $output_fh = *STDOUT; } else { - if (not open($output_fh, ">", $output)) { - error(4, "%s: %s\n", $output, $!); + if (not open($output_fh, ">", $output . "~")) { + error(4, "%s: %s\n", $output . "~", $!); } } @@ -159,6 +159,10 @@ sub compile if ($output ne "-") { close($output_fh); } + + if (not rename($output . "~", $output)) { + error(4, "%s: %s\n", $output, $!); + } } main();