我正在使用 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
的文档字符串。您可以将output
和error-output
都设置为:string
,这意味着它们将分别作为第一个和第二个返回值。第三个返回值是退出代码。您可以使用 multiple-value-bind
绑定(bind)这些值。如果 :on-error
为 nil
,则在非零退出代码的情况下不会发出错误信号。
例子:
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/