> > Does CMUCL provide a way to determine the location of the executable
> > that started it?
> > I understand that there's no portable solution that'll work for /all/
> > Unices but maybe there's a function that works on all systems CMUCL
> > has been ported to?
> After some poking around, it seems lisp::lisp-command-line-list
> contains the C argv array, so that would be a starting point. If
> argv[0] isn't an absolute path, you can probably combine that with
> (search-list "path:") to give you the full path name.
I know that the questions is how to do this from within CMUCL but I
found a few UNIX shell script snippets for doing this a while back.
Here is a Korn shell solution:
PRG=`whence $0` >/dev/null 2>&1
progname=`/usr/bin/basename $0`
proc=`/usr/bin/uname -p`
# Resolve symlinks, so that the pathname computations below find the
# directory structure they expect.
while [[ -h "$PRG" ]]; do
# Get the target of the symlink. N.B.: We assume that neither the
# link's value nor the pathname leading to it contains "-> ".
ls=`/usr/bin/ls -ld "$PRG"`
link=`/usr/bin/expr "$ls" : '^.*-> \(.*\)$'`
# If the link is absolute, use it as is; otherwise, substitute it
# into the leafname part of $PRG.
if /usr/bin/expr "$link" : '^/' > /dev/null; then
prg="$link"
else
prg="`/usr/bin/dirname $PRG`/$link"
fi
PRG=`whence "$prg"` >/dev/null 2>&1
done
I also found a Bourne shell snippet that does the same thing but it's
longer and I'll only post it if somebody wants to see it. One could
translate this idea into CL without too much effort, I would think.
--
Damien Kick