Handle .do files that start with "#!/" to specify an explicit interpreter.

Now you can have your .do files interpreted by whatever interpreter you
want.
This commit is contained in:
Avery Pennarun 2011-01-01 22:00:14 -08:00
commit f641e52e3b
7 changed files with 38 additions and 11 deletions

View file

@ -57,7 +57,13 @@ _run_dofile()
export DO_DEPTH="$DO_DEPTH "
export REDO_TARGET=$PWD/$TARGET
set -e
. "$PWD/$DOFILE" >"$TARGET.tmp2"
read line1 <"$PWD/$DOFILE"
cmd=${line1#"#!/"}
if [ "$cmd" != "$line1" ]; then
/$cmd "$PWD/$DOFILE" "$@" >"$TARGET.tmp2"
else
. "$PWD/$DOFILE" >"$TARGET.tmp2"
fi
}