How to use quicklisp when CL program is invoked as a shell script?

前端 未结 2 1750
日久生厌
日久生厌 2021-02-04 06:21

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 platfo

相关标签:
2条回答
  • 2021-02-04 06:38

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

    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> "$@"
      
    2. 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
      

    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.

    0 讨论(0)
  • 2021-02-04 06:40

    You are doing everything right.

    Basically, before you can use quicklisp, you need to load it (currently, it's not bundled with SBCL, although it may change in the future). There are various ways to do it. For example, you can load your .sbclrc with the quicklisp init:

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

    or just paste those lines in your script, like you have suggested.

    0 讨论(0)
提交回复
热议问题