minimal/do: make redo-ifchange (etc) into subprograms in a temp dir.

Using aliases for them was cute, but it didn't work with things like:

	find -name '*.c' | xargs redo-ifchange

since xargs doesn't know about aliases.
This commit is contained in:
Avery Pennarun 2010-12-11 21:47:55 -08:00
commit 80fedc84fe
2 changed files with 12 additions and 6 deletions

View file

@ -3,6 +3,7 @@ if [ -e .do_built ]; then
rm -f "$x" rm -f "$x"
done <.do_built done <.do_built
fi fi
[ -z "$DO_BUILT" ] && rm -rf .do_built .do_built.dir
redo t/clean redo t/clean
rm -f *~ .*~ */*~ */.*~ *.pyc rm -f *~ .*~ */*~ */.*~ *.pyc
rm -rf t/.redo rm -rf t/.redo

View file

@ -3,7 +3,7 @@
# A minimal alternative to djb redo that doesn't support incremental builds. # A minimal alternative to djb redo that doesn't support incremental builds.
# For the full version, visit http://github.com/apenwarr/redo # For the full version, visit http://github.com/apenwarr/redo
# #
export REDO="$(dirname "$0")/$(basename "$0")" export REDO="$(cd "$(dirname "$0")" && echo "$PWD/$(basename "$0")")"
if [ -z "$DO_BUILT" ]; then if [ -z "$DO_BUILT" ]; then
export DO_BUILT="$PWD/.do_built" export DO_BUILT="$PWD/.do_built"
@ -13,6 +13,16 @@ if [ -z "$DO_BUILT" ]; then
while read f; do rm -f "$f"; done while read f; do rm -f "$f"; done
mv "$DO_BUILT.new" "$DO_BUILT" mv "$DO_BUILT.new" "$DO_BUILT"
fi fi
DO_PATH="$DO_BUILT.dir"
export PATH="$DO_PATH:$PATH"
rm -rf "$DO_PATH"
mkdir "$DO_PATH"
for d in redo redo-ifchange; do
ln -s "$REDO" "$DO_PATH/$d";
done
for d in redo-ifcreate redo-stamp redo-always; do
ln -s /bin/true "$DO_PATH/$d";
done
fi fi
@ -81,12 +91,7 @@ redo()
} }
alias redo-ifchange="redo"
alias redo-ifcreate=":"
alias redo-stamp=":"
alias redo-always=":"
set -e set -e
if [ -n "$*" ]; then if [ -n "$*" ]; then
redo "$@" redo "$@"
else else