<div dir="ltr">I've used variations on this trick for a long time. ccl-script.sh follows:<div><br></div><div><div> ":" ; </div><div> #| Any necessary shell setup can go here</div><div><br></div><div> # Exec into Lisp</div><div> exec ccl -n --quiet --batch --load `which "$0"` -- ${1+"$@"}</div><div><br></div><div> # |#</div><div><br></div><div> (format t "Hello, world. Args: ~S~%" ccl:*command-line-argument-list*)</div><div> (format t "What's your name? ")</div><div> (force-output)</div><div> (format t "~&Hello, ~A~%" (read-line))</div><div> (ccl:quit)</div><div><br></div><div>Then:</div><div><br></div><div><div> $ ./ccl-script.sh 42</div><div> Hello, world. Args: ("ccl" "-n" "--quiet" "--load" "./ccl-script.sh" "--" "42")</div><div> What's your name? Bob</div><div><br></div><div> Hello, Bob</div></div><div><br></div><div>I learned it from Rob Warnock, who offers a few variations at <a href="http://xach.com/rpw3/articles/54KdndLa5cO9DErd4p2dnA%40speakeasy.net.html">http://xach.com/rpw3/articles/54KdndLa5cO9DErd4p2dnA%40speakeasy.net.html</a> and elsewhere in his archive.</div><div><br></div><div>Zach</div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 16, 2017 at 6:16 AM, Tim Bradshaw <span dir="ltr"><<a href="mailto:tfb@tfeb.org" target="_blank">tfb@tfeb.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What I do is something like this:<br>
<br>
#!/bin/sh -<br>
<br>
exec ccl -Q -b <<EOF<br>
(print "hi")<br>
EOF<br>
<br>
Which I think is perhaps not as robust, but works (note this depends on my ccl wrapper but that's mostly just a thing to avoid having to know what obscure path the executable is sitting in & to support recompiling &c).<br>
<span class="HOEnZb"><font color="#888888"><br>
--tim<br>
</font></span><div class="HOEnZb"><div class="h5">> On 16 Feb 2017, at 00:20, Ron Garret <<a href="mailto:ron@flownet.com">ron@flownet.com</a>> wrote:<br>
><br>
> Running ccl as a shebang script is not a supported feature. It turns out that it’s possible to do it, but it requires some horrible hackery: you have to define a reader macro that treats #! as a comment delimiter, and you have to put that in your ccl-init file. That seemed too ugly to me, so I wrote a little C program that reads past the first line of the script and pipes the rest into ccl’s stdin. That seemed like a cleaner solution. Just in case anyone else cared about this I thought I’d share the code:<br>
><br>
><br>
> ➔ cat cclsh.c<br>
> #include <stdlib.h><br>
> #include <unistd.h><br>
> #include <stdio.h><br>
> #include <fcntl.h><br>
><br>
> char *args[] = {"cclsh", "-Q", "-b"};<br>
><br>
> int main(int argc, char *argv[], char *envp[]) {<br>
> if (argc!=3) {<br>
> fprintf(stderr, "Usage: %s [path-to-ccl-executable] [path-to-script]",<br>
> argv[0]);<br>
> exit(-1);<br>
> }<br>
> int fd = open(argv[argc-1], O_RDONLY);<br>
> char c = ' ';<br>
> while (c!='\n') read(fd, &c, 1);<br>
> fclose(stdin);<br>
> dup(fd);<br>
> close(fd);<br>
> execve(argv[1], args, envp);<br>
> }<br>
><br>
><br>
> Example:<br>
><br>
> ➔ cat test<br>
> #!cclsh /Users/ron/devel/ccl/active/<wbr>dx86cl64<br>
> (list 1 2 3)<br>
> ➔ ./test<br>
> (1 2 3)<br>
><br>
> rg<br>
><br>
> ______________________________<wbr>_________________<br>
> Openmcl-devel mailing list<br>
> <a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>
> <a href="https://lists.clozure.com/mailman/listinfo/openmcl-devel" rel="noreferrer" target="_blank">https://lists.clozure.com/<wbr>mailman/listinfo/openmcl-devel</a><br>
<br>
______________________________<wbr>_________________<br>
Openmcl-devel mailing list<br>
<a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>
<a href="https://lists.clozure.com/mailman/listinfo/openmcl-devel" rel="noreferrer" target="_blank">https://lists.clozure.com/<wbr>mailman/listinfo/openmcl-devel</a><br>
</div></div></blockquote></div><br></div>