diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.lisp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main.lisp b/src/main.lisp index ce73d78..d9cd0f5 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -38,13 +38,18 @@ have passed or CHECK returns non-nil." (shell-name (parent-process-name)) (await-output-p 0.8) (output-stream *standard-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))) - (write-line command (uiop:process-info-input shell)) - (finish-output (uiop:process-info-input shell)) - (when await-output-p - (wait-until (:timeout await-output-p :poll-every 0.005) - (listen (uiop:process-info-output shell))) - (loop while (listen (uiop:process-info-output shell)) - do (princ (read-line (uiop:process-info-output shell)) output-stream) - (terpri output-stream))))) + (symbol-macrolet ((shell-input (uiop:process-info-input shell)) + (shell-output (uiop:process-info-output shell))) + (write-line command shell-input) + (finish-output shell-input) + (when await-output-p + (wait-until (:timeout await-output-p :poll-every 0.005) + (listen shell-output)) + (loop while (listen shell-output) + do (princ (read-line shell-output) output-stream) + (terpri output-stream)))))) |