[Openmcl-devel] Running ccl as a shebang script

Barry Fishman barry at ecubist.org
Thu Feb 16 06:27:50 PST 2017


On 2017-02-16 08:44:24 +05, Zach Beane wrote:
> I've used variations on this trick for a long time. ccl-script.sh follows:
>
>     ":" ;
>     #| Any necessary shell setup can go here
>
>     # Exec into Lisp
>     exec ccl -n --quiet --batch --load `which "$0"` -- ${1+"$@"}
>
>     # |#
>
>     (format t "Hello, world. Args: ~S~%" ccl:*command-line-argument-list*)
>     (format t "What's your name? ")
>     (force-output)
>     (format t "~&Hello, ~A~%" (read-line))
>     (ccl:quit)

Or similarly, since 'ccl' is a script that already does the shell setup:

--8<---------------cut here---------------start------------->8---
":" ; exec ccl --no-init --load "`which $0`" -- ${1+"$@"}
;;;; -*- lisp -*-
(defvar *program* (file-namestring
                   #.(or *compile-file-truename* *load-truename*)))
(defvar *args* *unprocessed-command-line-arguments*)

(format t "Program: ~a~%" *program*)
(do ((count 0 (1+ count))
     (args *args* (cdr args)))
    ((null args))
  (format t "Arg ~D = ~S~%" count (car args)))

(quit)
--8<---------------cut here---------------end--------------->8---

--
Barry Fishman




More information about the Openmcl-devel mailing list