X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Fssic.pl;h=750c77be6b9021a72284ed8cec2d844390c52c5d;hb=8f8a48ff1f02160cb769f76310564764f3e9ba78;hp=8ecc30e92104be274b2178284bcb3cb6bc9f9c45;hpb=c7dbd598e3cddc3161bc718f9ea9df6f15f8fdd6;p=ssic.git diff --git a/src/ssic.pl b/src/ssic.pl old mode 100644 new mode 100755 index 8ecc30e..750c77b --- a/src/ssic.pl +++ b/src/ssic.pl @@ -112,7 +112,7 @@ sub compile my $var_value; if ($input eq $output and $input ne "-") { - error(4, "Input and output files are equal\n"); + warning("Input and output files are equal\n"); } if ($input eq "-") { @@ -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 . "~", $!); } } @@ -152,6 +152,17 @@ sub compile } print($output_fh $ssi->process(<$input_fh>)); + + if ($input ne "-") { + close($input_fh); + } + if ($output ne "-") { + close($output_fh); + } + + if (not rename($output . "~", $output)) { + error(4, "%s: %s\n", $output, $!); + } } main();