如何在OS X上的Shell脚本中运行Clozure CL(Lisp)? [英] How to run Clozure CL (Lisp) from a shell script on OS X?

查看:97
本文介绍了如何在OS X上的Shell脚本中运行Clozure CL(Lisp)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下操作:

$ cat args.sh
\#! /Applications/ccl/dx86cl64
(format t "~&~S~&" *args*)

$ ./args.sh 

无法从./args.sh

我可以直接运行lisp:

I can run lisp fine directly:

$ /Applications/ccl/dx86cl64
Welcome to Clozure Common Lisp Version 1.5-r13651  (DarwinX8664)!

? 

是否可以编写Shell脚本以使用Clozure CL运行Lisp代码?我确定我做的事很愚蠢.

Is it possible to write a shell script to run lisp code with Clozure CL? I am sure I am doing something silly.

我从以下位置安装了它: http://openmcl.clozure.com/

I installed it from: http://openmcl.clozure.com/

推荐答案

只需跟进查理·马丁(Charlie Martin)的回答和您随后的问题. dx86cl64 --eval <code>将启动REPL,因此,如果要启动给定脚本然后退出,只需将其添加到脚本的末尾:(ccl::quit).在您提供的示例中,这将达到目的:

Just following up on Charlie Martin's answer and on your subsequent question. The dx86cl64 --eval <code> will fire up a REPL, so if you want to fire up a given script then quit, just add this to the end of your script: (ccl::quit). In the example you provided, this would do the trick:

#! /bin/bash 
exec /Applications/ccl/dx86cl64 --eval '(progn (format t "hello script") (ccl::quit))'

一个更好的脚本如下:

#! /bin/bash
exec /Applications/ccl/dx86cl64 -b -e '(progn (load "'$1'") (ccl::quit))'

将其放入文件load-ccl-script.sh(或您选择的其他名称)中.然后,以下交互将起作用:

Put that into a file, load-ccl-script.sh (or other name of your choice). Then the following interaction works:

$ echo '(format t "weeee!")' > a.lisp
$ sh load-ccl-script.sh a.lisp
weeee!
$ _

这篇关于如何在OS X上的Shell脚本中运行Clozure CL(Lisp)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆