mit-scheme — run a script and exit

喜你入骨 提交于 2019-12-21 12:51:32

问题


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 ?


回答1:


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




回答2:


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
}



回答3:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!