如何使用quicklisp当CL程序调用一个shell脚本? [英] How to use quicklisp when CL program is invoked as a shell script?

查看:197
本文介绍了如何使用quicklisp当CL程序调用一个shell脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在Common Lisp的,我想作为一个shell脚本运行的小程序。我使用SBCL和完美的罚款与此所以将preFER留在这个平台上。 :)

I am currently have a small program in Common Lisp, which I want to run as a shell script. I am using the SBCL and perfectly fine with this so will prefer to stay on this platform. :)

我知道有关 - 脚本选项,它完美的作品,除了(QL:quickload)形式

I am aware about the --script option and it works flawlessly except for (ql:quickload) form.

我的程序使用 CL-FAD ,通过加载QL: quickload (我想我应该指出,这是包装载功能从 quicklisp ) 。当脚本运行到评估

My program uses the CL-FAD, which loads through ql:quickload (I think I should mention that it is package-loading function from quicklisp). When script runs up to evaluating the

(ql:quickload :cl-fad)

形式,它打破下一个错误:

form, it breaks with the next error:

package "QL" not found

节目包装单个源文件中,其中有以下标题:

Program is packed in the single source file, which has following header:

(defpackage :my-package
  (:use :common-lisp)
  (:export :my-main-method))

这是简单自动化的可执行文件,所以我决定(可能错误地)没有写任何ASDF系统。它出口应该不带任何参数运行单一的功能。

It is simple automation executable, so I decided (maybe erroneously) not to write any ASDF system. It exports single function which should be run without any arguments.

有关这个节目我目前正在写的启动程序脚本,这就是我盯着:

For this program I am currently trying to write the launcher script, and this is what I am staring at:

#!/usr/bin/sbcl --script
(load "my-program.lisp")
(in-package :my-package)
(my-main-method)

这三条线(不包括家当)就是我想实现自动化。正如我在文档阅读,这家当脚本可以被称为简单的 ./ script.lisp ,它真的做到这一点......与之前​​描述的错误。

This three lines (not counting the shebang) is what I am want to automate. As I read in documentation, script with this shebang can be called as simple ./script.lisp, and it really does this... with the error described before.

我需要在发射增加对:CL-FAD 正确加载?文件指出,与 - 脚本选项SBCL不加载任何init文件,所以我真的需要copypaste行

What I need to add in the launcher for :cl-fad to load properly? Documentation states that with --script option SBCL doesn't load any init file, so do I really need to copypaste the lines

#-quicklisp
(let ((quicklisp-init (merge-pathnames "systems/quicklisp/setup.lisp"
                                       (user-homedir-pathname))))
  (when (probe-file quicklisp-init)
    (load quicklisp-init)))

(其中 QL:添加到初始化文件添加到.sbclrc),我的启动程序脚本?
也许我有一些深层次的建筑缺陷在我的计划设置?

(which ql:add-to-init-file adds to .sbclrc), to my launcher script? Maybe I have some deep architectural flaw in my program setup?

是的,当我输入我尝试在REPL自动在SBCL本身的线条,程序运行正常。

And yes, when I enter the lines which I try to automate in REPL in the sbcl itself, program runs as expected.

推荐答案

创建核心图像的专用版本是一个不错的选择。您可以:

Creating a dedicated version of core image is a good option. You may:


  1. 负荷 quicklisp SB-EXT:保存-LISP和模具在一个新的形象。你写一个名为一个shell /蝙蝠脚本,比如 qlsbcl ,就像这样:

  1. load quicklisp and sb-ext:save-lisp-and-die in a new image. You write a shell/bat script named, say qlsbcl, like this:

sbcl --core <my-new-image-full-path-location> "$@"


  • clbuild2 位于 http://gitorious.org/clbuild2和运行 clbuild口齿不清。你必须符号链接clbuild在路径二进制目录,如果调整​​某些脚本有点你的 quicklisp 不在共同的地方的〜/ quicklisp (https://gist.github.com/1485836),或者如果您使用 ASDF2 (https://gist.github.com/1621825)。通过这样做, clbuild 创建 quicklisp ASDF 和任何你可能会加入的 conf.lisp 的。现在的家当可能是这样的:

  • grab clbuild2 at http://gitorious.org/clbuild2 and run clbuild lisp. You'll have to symlink clbuild to a binary directory in your path and tweak some scripts a bit if your quicklisp is not in the common place ~/quicklisp (https://gist.github.com/1485836) or if you use ASDF2 (https://gist.github.com/1621825). By doing so, clbuild create a new core with quicklisp, ASDF and anything you may add in conf.lisp. Now the shebang may look like this:

    #!/usr/bin/env sbcl --noinform --core <my-clbuild-install-directory>/sbcl-base.core --script
    


  • clbuild 的好处是,你可以轻松地创建和 SBCL 管理​​从壳芯和quicklisp安装(默认情况下)或其他任何现代的CL像 ccl64 的实施。混合这两种技术(脚本和 clbuild ),将解决你的问题。

    The advantage of clbuild is that you may easily create and manage core and quicklisp installation from shell for sbcl (by default) or any other modern CL like ccl64 implementation. Mixing the two techniques (script and clbuild) will solve your problem.

    这篇关于如何使用quicklisp当CL程序调用一个shell脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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