common-lisp - 如何在 sbcl (common-lisp) 中使用 sb-ext :run-program? 的参数

标签 common-lisp sbcl

我正在尝试通过 SBCL 的 sb-ext:run-program 在 common-lisp 中调用外部 shell 命令。

有关此运行程序命令的文档可以在此处找到: http://sbcl.org/manual/index.html 在该部分 7.7.3 运行外部程序

该页面不包含示例。通过检查此页面,我弄清楚了如何使用它: stackoverflow examples for sb-ext:run-program

这就是我想做的事...

首先,我为参数定义一个变量:

(defconstant *a-argument* "-lh")

然后我调用命令:

(sb-ext:run-program "C:\\Program Files (x86)\\Gow\\bin\\ls.exe"
                    '(*a-argument*)
                    :output *standard-output*)

它给了我以下错误:

debugger invoked on a TYPE-ERROR in thread
#<THREAD "main thread" RUNNING {100299C8F3}>:
  The value
    *A-ARGUMENT*
  is not of type
    SEQUENCE

但是,如果我这样调用它:

(sb-ext:run-program "C:\\Program Files (x86)\\Gow\\bin\\ls.exe"
                    '("-lh")
                    :output *standard-output*)

然后就可以了。唯一的区别是直接使用 "-lh",而不是 *a-argument*

所以我的问题是:
要使用参数列表中的变量来使运行程序调用正常工作,我需要做什么?

额外信息:

windows32 2.6.1 7601 i686-pc Intel unknown MinGW
SBCL 1.3.8

但是我也在 FreeBSD 10.1 上测试了这个,我也遇到了同样的问题。

最佳答案

jkiiski给出了答案:

我需要更改此调用:

(sb-ext:run-program "C:\\Program Files (x86)\\Gow\\bin\\ls.exe"
                    '(*a-argument*)
                    :output *standard-output*)

对于此电话:

(sb-ext:run-program "C:\\Program Files (x86)\\Gow\\bin\\ls.exe"
                    (list *a-argument*)
                    :output *standard-output*)

关于common-lisp - 如何在 sbcl (common-lisp) 中使用 sb-ext :run-program? 的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39163237/

相关文章:

lisp - CentOS 7 上的 Common Lisp

common-lisp - 如何使用输出指针参数调用外部函数?

common-lisp - 在使用递归连接函数格式后,在 Common Lisp 中打印字符串

optimization - 在 Lisp 中,使用 let* 还是 setf 更惯用?

lisp - 比较 Common Lisp 中 AllegroGraph Prolog 中的 RDF 文字

common-lisp - 为什么不能并行执行编译文件?

lisp - 创建大量的gensym是否合理?

macros - 如何在宏调用中使用参数?

lisp - 如何在 Common Lisp 中分解或拼接列表?

com - 是否有开源的 Common Lisp COM 包装器?