> Are you trying to figure out whether a particular file is the "main
> script" as opposed to being loaded from some other script?
>
Yes. There's no standard name for the behavior of bundling a package API
with a usable CLI in a single code file, so I've taken to calling it
"scripted main" and begun documenting on Rosetta
Code<http://rosettacode.org/wiki/Scripted_main&gt; how
to achieve this in a variety of programming languages. Another word for
programs this is "modulino".
> One way to do this is to check your own variable *main* and bind it if
> it is not bound already. This is portable.
> Another way is to use SYS::*LOAD-LEVEL*, which is bound to incremented
> values by LOAD.
>
Yeah, so I'm looking for a simpler way to do this. Some languages expose
this via a variable, like $0, or a single function call.
Yet another way is EXT:ARGV
> http://clisp.org/impnotes/environment-enq.html#argv
This isn't portable. It involves CLISP-specific parsing to reliably extract
the script name, so the same code can't be used in ECL, CCL, ABCL, ...
I like my code to be very portable.
> 2 years ago you asked about this here:
>
> http://sourceforge.net/tracker/?func=detail&aid=3124233&group_id=1355&atid=351355
> can you offer a better rationale than then?
>
I agree that modifying the output of ext:*args* would break reverse
compatibility.
I agree that we don't want to break reverse compatibility.
So I'll tweak my suggestion and request that CLISP provides another
function much like ext:*args*, except that it exposes an equivalent to C's
argv[0].
An easy way to satisfy this is to make a function ext:*argv0*.
--
Cheers,
Andrew Pennebaker
http://www.yellosoft.us

Many CL's offer a way to retrieve the Lisp script name, but CLISP appears
to silently drop this information. I've managed a hack around this, but not
without caveats.
https://github.com/mcandre/scriptname/blob/master/scriptname.lisp
A shebang line forces the script name onto the shell arguments twice,
forcing it into ext:*args*. However, this method only works when the Lisp
script is run with Unix ./ notation (chmod a+x && ./scriptname.lisp), and
the script must be run with CLISP; Thus the script immediately loses
portability to other CL's which require their own shebangs.
Could CLISP please provide an accessor similar to ext:*args* that exposes
argv[0], as a C program would see it? Thank you.
--
Cheers,
Andrew Pennebaker
http://www.yellosoft.us