summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-09-22 17:39:34 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-09-22 17:42:08 (EDT)
commit4044ca6ad9ed9a23b873036b1225e2d424fa7031 (patch)
tree918bd57654c7fc26fa799c5e99f78d71bdb53498
parent38cef4993526f480eb5e54661acb5f655d0323c0 (diff)
downloadssic-4044ca6ad9ed9a23b873036b1225e2d424fa7031.zip
ssic-4044ca6ad9ed9a23b873036b1225e2d424fa7031.tar.gz
ssic-4044ca6ad9ed9a23b873036b1225e2d424fa7031.tar.bz2
Write to a temporary file.
-rw-r--r--src/ssic.pl8
1 files changed, 6 insertions, 2 deletions
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();