aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-11 16:11:53 -0600
committerColin Okay <okay@toyful.space>2022-02-11 16:11:53 -0600
commitb0187734d06f10ee1f8d7b40bb3325761571159b (patch)
treeb605e80591bd388e61c873882753c174eca5e0d0
parentb05761610ebe7f31f172cc421c22738295f99931 (diff)
added docstring to run-with-shell
-rw-r--r--src/main.lisp21
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))))))