Sim
Sim

Reputation: 4185

How to use additional flags when creating lisp script file to start from console

I want to create a .lisp file which I can start as script, i.e., with a leading #!/bin/usr/sbcl --script. This works just fine.

File:

#!/usr/bin/sbcl --script
(format t "test~%")

Output:

$> ./test.lisp
test

However, I also need to adjust the dynamic space size for that particular script to work. But this somehow prevents the --script flag from working

File:

#!/usr/bin/sbcl --dynamic-space-size 12000 --script
(format t "test~%")

Output:

$> ./test.lisp
This is SBCL 1.4.5.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
*

How can I increase the dynamic space size while keeping the convenience of starting the lisp program/script from the command prompt?

Upvotes: 0

Views: 151

Answers (2)

Svante
Svante

Reputation: 51501

This is a general limitation of shebang lines and not SBCL specific.

Newer env versions (in GNU — FreeBSD has had this a bit longer) understand a -S option to split the argument:

https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html#g_t_002dS_002f_002d_002dsplit_002dstring-usage-in-scripts

#!/usr/bin/env -S sbcl --dynamic-space-size 9000 --script

Upvotes: 2

Sim
Sim

Reputation: 4185

Apparently the #! considers everything following the command as a single string and thus --dynamic-space-size 12000 --script is treated as one and not as a parameter and a flag.

My current solution is to create an additional .sh file:

#!/bin/bash
sbcl --dynamic-space-size 12000 --script ./test.lisp $@

However, this has the obvious downside that the script needs to be started from the same directory as the .lips file. Consequently, I am still looking for the 'perfect' solution and this is rather a stop-gap.

Upvotes: 0

Related Questions