From b0187734d06f10ee1f8d7b40bb3325761571159b Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 11 Feb 2022 16:11:53 -0600 Subject: added docstring to run-with-shell --- src/main.lisp | 21 +++++++++++++-------- 1 file 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)))))) -- cgit v1.2.3