lisp - 劣质壳实时打印输出

标签 lisp common-lisp sbcl

我正在使用 inferior-shell:run 来启动一个长时间运行的任务,该任务通常会失败(这是一个构建验证例程)。

我的主要问题是我找不到查看已启动事件的“实时”输出的方法。

我之所以喜欢直播,是因为如果发生错误,我看不到输出;我查看了 ON-ERROR: 键,但它的结果只不过是说退出代码为 1。这是有道理的,因为看起来这个键是采取某种方式的回调的恢复行动。但是,如果我的任务失败了,我还想知道它失败的原因,而这隐藏在命令的输出中,似乎无法访问。

我试过像这样调用 RUN:

(inferior-shell:run
    (pod-command file)        ; this generates a string shell
                              ;   command from the arg FILE
    :on-error #'print         ; tells me that the exit code was 1 
    :output *standard-output* ; default, if I understand correctly
    :interactive t)           ; this was a shot in the dark

即使在成功的案例中,在生成时(而不是在最后)看到输出仍然是件好事,但这只是锦上添花。

我才刚刚开始学习 Lisp,所以如果我错过了一些明显的东西,我深表歉意。

我正在使用 sbcl 中的 quickload 加载 inferior-shell

最佳答案

查看inferior-shell:run 的文档字符串。您可以将outputerror-output都设置为:string,这意味着它们将分别作为第一个和第二个返回值。第三个返回值是退出代码。您可以使用 multiple-value-bind 绑定(bind)这些值。如果 :on-errornil,则在非零退出代码的情况下不会发出错误信号。

例子:

CL-USER> (inferior-shell:run "git status"
                             :on-error nil
                             :error-output :string
                             :output :string)
""
"fatal: Not a git repository (or any of the parent directories): .git
"
128

关于lisp - 劣质壳实时打印输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44463420/

相关文章:

list - Elisp:如何查找列表重复项

lisp - gensym 在 Lisp 中做了什么?

lisp - Common-LISP Print 函数本身

emacs - emacs lisp 中惯用的序列化方式

package - 如何导入外部包符号并排除一些

list - 这个 Common Lisp 代码与他们在 Winston/Horn 的 LISP 第三版中教授的内容相似/相同吗?

garbage-collection - 哈希表疑似SBCL垃圾回收Bug

lisp - 如何从 Lisp 类导出槽和访问器?

common-lisp - 我可以在 SBCL 或 CLISP 中使用由 Allegro Common Lisp 制作的 C++ 包装器吗

emacs - 在 "Slime"(最新版本)中设置 "emacs"时,我如何告诉它更快地加载 swank?