[Openmcl-devel] Why cannot i use the shebang ?

Pascal J. Bourguignon pjb at informatimago.com
Thu Aug 1 18:26:04 PDT 2013

czsq888 <czsq888 at 163.com> writes:

> $head make-image-ccl.lisp
> #!/bin/sh
> #|
> exec ~/ccl/fx86cl -Q -n -l $0
> |#
> (load "~/quicklisp/asdf")
> ..
> $./make-image-ccl.lisp
>  ("~/make-image-ccl.lisp"/6 UTF-8) #x3837D91E>, near position 2, within
>  "#!/bin/sh
>>        #|":
>>        Undefined character #\! in a #\# dispatch macro.

The error message is clear!  There's no dispatching reader macro defined
for #\# #\! !  
The solution is obvious: define one such dispatching reader macro!

The trick is that you're passing options to ccl to avoid reading the rc
file, so you can't define the dispatching reader macro there.  You seem
to be wanting to use a standard image, so you can't define it in the
image either.  And since the #! are the first character of the script,
you can't define it in the script either! So the only option left is to
define it on the command line invoking ccl.

Here is a script that works:
exec ccl -e '(set-dispatch-macro-character #\# #\! 
                (lambda (stream subchar arg)
                  (declare (ignore subchar arg))
                  (read-line stream)
                  (values)))' \
         -Q -n -l "$0" -- "$@"
(setf *load-verbose* nil *load-print* nil)
(load "~/quicklisp/setup.lisp" :verbose nil)
(let ((*standard-output* (make-broadcast-stream))
      (*trace-output* *standard-output*))
  (ql:quickload :alexandria))
(prin1 (alexandria:iota 20))

(defparameter *arguments* (subseq ccl:*command-line-argument-list* 
                                  (1+ (or (position "--" ccl:*command-line-argument-list* :test 'string=) -1))))
(prin1 *arguments*)
(ccl:quit 0)

__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.  
You know you've been lisping too long when you see a recent picture of George 
Lucas and think "Wait, I thought John McCarthy was dead!" -- Dalek_Baldwin

More information about the Openmcl-devel mailing list