【发布时间】:2010-06-10 22:59:04
【问题描述】:
我正在尝试为 clisp 创建一个像这样工作的“系统”命令
(setq result (system "pwd"))
;;now result is equal to /my/path/here
我有这样的事情:
(defun system (cmd)
(ext:run-program :output :stream))
但是,我不确定如何将流转换为字符串。我已经多次审查了 hyperspec 和 google。
编辑:使用 Ranier 的命令并使用 with-output-to-stream,
(defun system (cmd)
(with-output-to-string (stream)
(ext:run-program cmd :output stream)))
然后尝试运行grep,它在我的路径中......
[11]> (system "grep")
*** - STRING: argument #<OUTPUT STRING-OUTPUT-STREAM> should be a string, a
symbol or a character
The following restarts are available:
USE-VALUE :R1 Input a value to be used instead.
ABORT :R2 Abort main loop
Break 1 [12]> :r2
【问题讨论】: