[创建从控制台启动的Lisp脚本文件时如何使用其他标志

问题描述 投票:0回答:2

我想创建一个.lisp文件,该文件可以作为脚本启动,即以前导#!/bin/usr/sbcl --script开始。这样就可以了。

文件:

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

输出:

$> ./test.lisp
test

但是,我还需要调整动态空间大小以使特定脚本起作用。但这以某种方式阻止了--script标志的工作

文件:

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

输出:

$> ./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.
*

如何增加动态空间的大小,同时又保持从命令提示符启动lisp程序/脚本的便利?

common-lisp sbcl
2个回答
2
投票

这是shebang行的一般限制,而不是特定于SBCL。

[较新的env版本(在GNU中-FreeBSD拥有了更长的时间)了解用于拆分参数的-S选项:

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

0
投票

[显然,#!将命令后的所有内容都视为一个字符串,因此--dynamic-space-size 12000 --script被视为1,而不是参数和标志。

我当前的解决方案是创建一个附加的.sh文件:

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

但是,这样做的明显缺点是,脚本需要从与.lips文件相同的目录中启动。因此,我仍在寻找“完美”的解决方案,这是一个权宜之计。

© www.soinside.com 2019 - 2024. All rights reserved.