我使用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,所以如果我错过了一些明显的东西,我会道歉。
我在inferior-shell
quickload
sbcl
{/ 1}}
答案 0 :(得分:1)
查看inferior-shell:run
的文档字符串。您可以将output
和error-output
都设置为:string
,这意味着它们将分别是第一个和第二个返回值。第三个返回值是退出代码。您可以使用multiple-value-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