Clozure CL 编译的可执行文件丢失某些命令行参数

Clozure CL compiled executable losing certain command line arguments

我正在用 Common Lisp 编写实用程序并使用 Clozure CL 构建它;我希望能够在程序中使用命令行选项 -d,但由于某些原因 这个 特定选项无法通过 (ccl::command-line-arguments).这是一个最小的例子:

(defun main ()
  (format t "~s~%" (ccl::command-line-arguments))
  (quit))

我用

编译
(save-application "opts"
  :toplevel-function 'main
  :prepend-kernel t)

这是一些示例输出:

~/dev/scratch$ ./opts -c -a -e
("./opts" "-c" "-a" "-e")
~/dev/scratch$ ./opts -c -d -e
("./opts" "-c" "-e")
~/dev/scratch$ ./opts -b --frogs -c -d -e -f -g -h --eye --jay -k -l
("./opts" "--frogs" "-c" "-e" "-f" "-g" "-h" "--eye" "--jay" "-k" "-l")

-b-d 选项似乎丢失了。 command line arguments for ccl isn't very helpful. I thought maybe because ccl itself takes -b as an argument, that option might have gotten eaten for some reason, but it doesn't take -d (which is eaten), and it does take -e and -l which aren't. Nothing on saving applications 上的文档似乎很有帮助。

我很确定它是特定于 Clozure 的(而不是 shell 吃掉它们),因为其他东西似乎得到了所有论点:

#!/usr/bin/python
import sys
print sys.argv

产量

~/dev/scratch$ ./opts.py -a -b -c -d -e
['./opts.py', '-a', '-b', '-c', '-d', '-e']

#!/bin/bash
echo "$@"

给予

~/dev/scratch$ ./opts.sh -a -b -c -d -e
-a -b -c -d -e

这一切都发生在 lubuntu 15.10 上,bash 作为 shell。

如果有人能阐明为什么会发生这种情况,或者我如何结束所有命令行开关,我将不胜感激。

谢谢。

根据1.11版本的源代码,-b-d是lisp内核使用的选项。

由于我不确定许可证问题,所以我只是将 link 提供给相关文件:http://svn.clozure.com/publicsvn/openmcl/release/1.11/source/lisp-kernel/pmcl-kernel.c

命令行参数在函数 process_options 中处理,其中选项 -b (--batch) 和 -d (--debug) - 等等- 变量 num_elide 设置为 1。再往下一点,这会导致用以下参数 (argv[k] = argv[j];).

覆盖选项

该代码还显示了一个可能的修复方法:在 -b-d 之前提供一次 --(两个破折号)作为参数。当上面的函数遇到 -- 时,它会停止处理其余的参数,从而使它们保持不变,以便可能在不久之后被吸收到 "lisp world" 中。


原来这已经在 SO 之前解决了: