Reputation: 2519
I'm using inferior-shell:run
to launch a long-running task which can routinely fail (it's a build validation routine).
My main issue is that I could not find a way of seeing the "live" output of the launched activity.
The reason why I'd like a live-feed is because I could not see the output if an error happened; I looked into the ON-ERROR:
key, but it yielded little more than saying that there was an exit code of 1. This makes sense, as it seems like this key is a callback to take some kind of recovery action. However, if my task fails, I'd also like to know why it failed, and that's hidden in the output of the command, which does not seem to be accessible.
I tried calling RUN
like this:
(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
Even in the success case, it would still be nice to see output as it's being produced (instead of at the end) but that's just a nice-to-have.
I'm only just beginning to learn Lisp, so I apologize if I missed something obvious.
I'm loading inferior-shell
with quickload
in sbcl
Upvotes: 1
Views: 364
Reputation: 51501
Take a look at the documentation string of inferior-shell:run
. You can set both output
and error-output
to :string
, which means that they will be the first and second return value, respectively. The third return value is the exit code. You can bind these values with multiple-value-bind
. If :on-error
is nil
, no error will be signalled in the case of a non-zero exit code.
Example:
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
Upvotes: 1