NB: These days you might prefer inferior-shell for its wider support and richer interface.
Quick assessment (2024-03-24)
- Tested with MKCL 1.1.11.195 on openSUSE Tumbleweed.
- Not actively maintained, so it needs a patch to support MKCL.
- Not very platform-independent, since it requires Bourne shell.
- Not to be confused with this trivial-shell, which is for Roswell.
- Has several users, including clesh and graph-utils.
> (apropos 'run :mkcl) RUN-COMMAND Function RUN-PROGRAM-1 Function RUN-PROGRAM Function GET-INTERNAL-RUN-TIME Function FTRUNCATE Function TRUNCATE Function GET-INTERNAL-RUN-TIME Function FTRUNCATE Function TRUNCATE Function
Here we have mkcl:run-command, which is what's used by compiler::run-command to call out to GCC. On Windows, it uses CreateProcessW, whereas on Unix, it uses either execv(3) or execvp(3). There's also mkcl:system, which corresponds to system(3) and it's what uiop:run-program uses when :force-shell t is specified. If we use mkcl:run-program, then trivial-shell::%shell-command will look like this:
(defun trivial-shell::%shell-command (command input)
(trivial-shell::with-input (input-stream (or input :none))
(multiple-value-bind (two-way-stream shell-process exit-status)
(mkcl:run-program trivial-shell::*bourne-compatible-shell*
(list "-c" command)
:input input-stream
:output :stream
:error :stream
:wait t)
;; Grab everything from the ERROR and OUTPUT streams.
(let* ((error-stream (mkcl:process-error shell-process))
(output (trivial-shell::file-to-string-as-lines two-way-stream))
(error (trivial-shell::file-to-string-as-lines error-stream)))
(close two-way-stream)
(close error-stream)
(values output
error
exit-status)))))
Clearly, the option :wait t (the default) depends on whether the command is run interactively or is expected to return immediately.
MIT-LICENSE