将引号传递给Clozure的运行程序的正确方法是什么?以调用echo ",应该返回“的简单例子为例。
然而,当我试图使用ccl: run -program运行这个命令时,如下所示,返回以下字符串:"\“而不是”\“。对于如何解决这个问题,有什么想法吗?最后的目标是将一个被引号包围的字符串作为参数传递给程序。
(with-output-to-string (stream)
(ccl:run-program "echo" (list "\"") :output stream)
)发布于 2022-10-28 14:23:50
在尝试您的代码时,我看到以下输出:
Clozure Common Lisp Version 1.12 (v1.12) LinuxX8664
For more information about CCL, please see http://ccl.clozure.com.
CCL is free software. It is distributed under the terms of the Apache
Licence, Version 2.0.
? (with-output-to-string (stream)
(ccl:run-program "echo" (list "\"") :output stream)
)
"\"
"
? 但是一些字符是在公共Lisp字符串中转义的,因此为了确定字符串包含什么,下面是不同的选项:
? (coerce * 'list)
(#\" #\Newline)或,
? (describe **)
"\"
"
Type: (SIMPLE-BASE-STRING 2)
Class: #<BUILT-IN-CLASS SIMPLE-BASE-STRING>
Length: 2
0: #\"
1: #\Newline`因此,据我所知,输出是理想的。
https://stackoverflow.com/questions/74233859
复制相似问题