diff options
-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)))))) |