Skip to content

Allow saved applications to disable runtime option processing - #559

Open
luciusmagn wants to merge 2 commits into
Clozure:masterfrom
luciusmagn:lho/fix/saved-application-arguments
Open

Allow saved applications to disable runtime option processing#559
luciusmagn wants to merge 2 commits into
Clozure:masterfrom
luciusmagn:lho/fix/saved-application-arguments

Conversation

@luciusmagn

Copy link
Copy Markdown
Contributor

Hi, I would like to propose a solution to the issue that the lisp kernel invariably eats some arguments before -- which may be used by other applications.

To describe it better, CCL’s kernel removes recognized runtime options before a saved application’s Lisp toplevel runs, which means that application flags such as --batch, --debug, -R, and -S can disappear or be misinterpreted. Saved applications with an explicit toplevel also do not receive arguments following -- through *UNPROCESSED-COMMAND-LINE-ARGUMENTS*.

I recognize that there is a lot of prior art and discussion to this topic (it is possible I missed some, so this list is probably not exhaustive and there may have been some things outside of github also):

This issue is particularly important for me, because I am developing CCLSH, which should support an open-ended argument vocab since it can be used to call arbitrary scripts, and these conflicts could bite me, or somebody else, in the ass, hypothetical scenario:

cclsh script.sh.lisp --opt1 -x -R report -S serve

Especially since hypothetically, the options that concern the kernel could change in the future and scripts that work before may not work anymore.

Solution

My solution adds an optional :PROCESS-RUNTIME-OPTIONS option to CCL:SAVE-APPLICATION, which defaults to the current behavior when omitted, so that we don't affect prior software.

When set to NIL, this policy is recorded in the saved image. For a embedded or default marked image, the kernel detects it before option scanning and leaves runtime-looking arguments untouched. When a marked image is selected through -I, runtime options before it can still configure the kernel, while subsequent args belong to the application

I also initialize *UNPROCESSED-COMMAND-LINE-ARGUMENTS* for explicit toplevel functions, giving standalone programs a reliable&complete path to args without affecting existing images.


Unlike wrappers or UIOP or app-level parsing, this solution happens before the kernel irreversibly removes args. Recording the policy in the image makes it generic and opt-in, not dependent on executable names, and compatible with CCL images that already exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant