diff options
author | Colin Okay <colin@cicadas.surf> | 2022-09-15 15:26:49 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-09-15 15:26:49 -0500 |
commit | 6e8edfe8ab7d1902bdfa54fe83d38a61a35a3f15 (patch) | |
tree | 014a4bdb90adf39de9693abd6d8913461c2ec1d5 /lib | |
parent | 4c43e044f3bbe51b78c99a2027ea3fddb36c5821 (diff) |
Refactor: to listen on stdout and stderr, and pritn accordingly
Diffstat (limited to 'lib')
-rw-r--r-- | lib/running.lisp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/running.lisp b/lib/running.lisp index b3a0b52..e4f9d63 100644 --- a/lib/running.lisp +++ b/lib/running.lisp @@ -36,21 +36,36 @@ have passed or CHECK returns non-nil." &key shell-name await-output-p - (output-stream *standard-output*)) + (output-stream *standard-output*) + (error-stream *error-output*)) "run COMMAND, a string, in a fresh shell environment, initialized with SHELL-NAME. The output from the command read line by line and is printed to OUTPUT-STREAM. " (let ((shell - (uiop:launch-program shell-name :input :stream :output :stream))) - (let ((shell-input (uiop:process-info-input shell)) - (shell-output (uiop:process-info-output shell))) + (uiop:launch-program + shell-name + :input :stream + :output :stream + :error-output :stream))) + (let ((shell-input + (uiop:process-info-input shell)) + (shell-err + (uiop:process-info-error-output shell)) + (shell-output + (uiop:process-info-output shell))) (write-line command shell-input) (finish-output shell-input) (when (and await-output-p (plusp await-output-p)) (loop while (wait-until (:timeout await-output-p :poll-every 0.05) - (listen shell-output)) - do (princ (read-line shell-output) output-stream) - (terpri output-stream)))))) + (or + (listen shell-err) + (listen shell-output))) + when (listen shell-output) + do (princ (read-line shell-output) output-stream) + (terpri output-stream) + else + do (princ (read-line shell-err) error-stream) + (terpri error-stream)))))) |