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 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
www.yellosoft.us