From 4044ca6ad9ed9a23b873036b1225e2d424fa7031 Mon Sep 17 00:00:00 2001 From: "P. J. McDermott" Date: Sun, 22 Sep 2013 17:39:34 -0400 Subject: [PATCH] Write to a temporary file. --- src/ssic.pl | 8 ++++++-- 1 file 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(); -- 2.31.1