summaryrefslogtreecommitdiff
path: root/setup.rc
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2016-04-16 02:02:51 -0700
committerMichael Forney <mforney@mforney.org>2016-04-16 02:02:51 -0700
commit00b7a0a40be589731b43df4934108f628a407f6b (patch)
tree0b02d28b4d587d4c0cdd5a29a245bac001e0038d /setup.rc
parent142c5870a9b6ba6f4d7af7bbdf46a72c22ee2983 (diff)
Write to local.ninja.tmp first in case generation fails
Diffstat (limited to 'setup.rc')
-rwxr-xr-xsetup.rc5
1 files changed, 3 insertions, 2 deletions
diff --git a/setup.rc b/setup.rc
index 4bd176cb..02a31934 100755
--- a/setup.rc
+++ b/setup.rc
@@ -32,6 +32,7 @@ fn gen {
if not dir=$dir/$1
cd $1
+ ifs=() { oldcwd=`{pwd | head -c -1} }
tree_perms=()
perms_inputs=()
@@ -45,7 +46,6 @@ fn gen {
set outdir $outdir
}
- ifs=() { oldcwd=`{pwd | head -c -1} }
. ./gen.rc
build 'phony/$srcdir/gen' phony '$srcdir'/local.ninja $gen_inputs
@@ -59,7 +59,8 @@ fn gen {
if not build '$outdir/root.perms' cat $perms_inputs
if(~ $#tree_inputs 0) build '$outdir/root.tree' stamp
if not build '$outdir/root.tree' cat $tree_inputs
- } >local.ninja
+ } >local.ninja.tmp
+ mv $oldcwd/^( local.ninja.tmp local.ninja )
if(! ~ $quiet 1) echo 'generated '$dir >[1=2]
status=()