Don't crash on targets in directories that don't exist yet.

The reason we'd crash is that we tried to pre-create a file called
$target.redo.tmp, which wouldn't work because the directory containing
$target didn't exist.

We now try to generate a smarter filename by using the innermost directory
of target that *does* exist.  It's a little messy, but the idea is to make
sure we won't have to rename() across a filesystem boundary if, for example,
there's a mounted filesystem in the middle of the hierarchy somewhere.
This commit is contained in:
Avery Pennarun 2011-03-22 22:09:56 -07:00
commit 2efbbc26b9
3 changed files with 47 additions and 16 deletions

View file

@ -1,7 +1,7 @@
rm -rf t/.redo redo-sh
if [ -e .do_built ]; then
while read x; do
rm -f "$x"
[ -d "$x" ] || rm -f "$x"
done <.do_built
fi
[ -z "$DO_BUILT" ] && rm -rf .do_built .do_built.dir