[Openmcl-devel] Using OpenMCL as a shell scripting interpreter
Gary Byers
gb at clozure.com
Mon Mar 29 05:45:39 PST 2004
On Sun, 28 Mar 2004, Stonewall Ballard wrote:
> I haven't had much time to work on this, so I'd appreciate any help I
> can get.
>
> Aside from replicating some of my Python utility scripts in Lisp to see
> whether I feel comfortable with using it that way, my other problem is
> how to coerce openmcl to run from a simple text file. I'm not going to
> make a megabyte image for every script - I need to keep them as text
> until they're run, just like other shell languages.
>
> I've tried invoking openmcl with a #! first line in a file, and while
> openmcl apparently runs, it doesn't go anywhere. I would have thought
> that:
>
> #!/usr/local/bin/openmcl -V
>
> would print the version number, but I can't find the output anywhere.
I don't see any evidence that the shell script is even invoked in this
case.
If you change the first line to refer to the executable and save that
in a text file called "showversion", as in:
#!/usr/local/src/ccl/dppccl -V
the executable will be invoked as
argv[0] = "dppccl" (not "/usr/local/src/ccl/dppccl")
argv[1] = "-V"
argv[2] = "showversion"
dppccl expects (naively) to have been invoked with its own full pathname,
and uses that to find the default image name.
To get that to work, I think that we'd have to
(a) use some other technique to find the executable's own pathname
and derive the default image name from it.
(b) change the command-line parsing so that the script name has some
meaning. (Currently, a random file name - not preceded by "--load"
or "--eval" or something - isn't interpreted sensibly.)
You could almost get (b) to work by doing something like
#!/usr/local/src/ccl/dppccl --load
though of course loading such a file would complain that the reader
macro #! is undefined. (I suppose that you could make #! behave as
; does.)
As far as (a) goes: I know how to do this under Linux; on Darwin, I
can't think of a way to do this without doing what "ps" does, which
many involve the use of things that Apple considers "unstable". I may
be forgetting something obvious; does anyone know of a "stable" way to
obtain the full pathname of the current process's executable under
Darwin ?
More information about the Openmcl-devel
mailing list