"Far=E9" <fahree@...> writes:
> Is there a way to store invocation arguments in an sbcl executable?
> That would be a very useful thing to do to allow deployment of
> applications that don't behave in a weird way if given magical
> command-line arguments. Only then can I truly get rid of a shell
> wrapper when cl-launch is to create a standalone executable.
> The trick: save a list of arguments when you save-lisp-and-die
> :executable t, in a way suitable for use by the C layer. Have the C
> layer prepend (logically or physically) this list to the list of
> actual arguments given on invocation.
> Is this the Right Thing to do? Are there any catches I should be aware
> of when trying to implement it?
It's probably the right thing, and was briefly discussed before the
executable patch was merged. At that time, we decided to wait until
there was real user experience with the executable delivery before
doing this part, since it wasn't completely clear whether this kind of
functionality was really needed. Looks like it is.
The basic implementation should be pretty straightforward. Something
* Add a new static symbol in src/compiler/generic/parms.lisp
(remember to export the symbol from SB!VM in
package-data-list.lisp-expr, otherwise genesis won't make it
visible in C)
* Set the value of the symbol to the desired argument vector before
saving the core
* Look up the argument vector from the symbol after restoring the core
I guess the only tricky bit is that you need to parse runtime
arguments twice (once from argv before loading the core, once after it
from the supplied vector), and then merge the non-runtime arguments.