I want to evaluate a script from makefile and exit, like this
mit-scheme --load "fact.scm"
However, after it evaluates the file, it does not exit, and the repl appears; if I try the (exit)
primitive, it asks for confirmation y/n. Is it possible to solve this ?
For Unix mit-scheme reads the input files via redirection:
mit-scheme < /usr/cph/foo.in > /usr/cph/foo.out 2>&1 &
This is taken from the documentation http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/Command_002dLine-Options.html#Command_002dLine-Options
Just let our command close stdin of the mit-scheme process automatically, e.g.
echo | mit-scheme --load sample.scm
We can expand it to a script function; here's my unskilled implementation:
function mschm () {
IFS=""
for arg in $@
do
echo | mit-scheme --load $arg
done
}
You can add the --quiet
argument to the mit-scheme
command to suppress the default output. This is otherwise a crib of Charlie Forthmount's function (though it only loads one file):
run-mit-scheme ()
{
echo | mit-scheme --quiet --load $1;
# Add an extra newline
echo
}
来源:https://stackoverflow.com/questions/24720112/mit-scheme-run-a-script-and-exit