[Openmcl-devel] Using OpenMCL as a shell scripting interpreter
gb at clozure.com
Wed Mar 31 11:33:51 EST 2004
On Mon, 29 Mar 2004, Gary Byers wrote:
> 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 = "dppccl" (not "/usr/local/src/ccl/dppccl")
> argv = "-V"
> argv = "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 ?
The function _NSGetExecutablePath was introduced in Jaguar; it returns
the pathname of the current executable file (which may not be the same
thing as argv). In Linux, /proc/exe/self is a symbolic link to the
More information about the Openmcl-devel