Does there exist standard way to run external program in Common Lisp?

前端 未结 6 1667
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-11 15:07

In clisp, the following code works:

(defun hit-history () (shell \"tail ssqHitNum.txt\"))

However, in Clozure CL, the shell fu

6条回答
  •  情歌与酒
    2021-01-11 15:55

    Yes, with UIOP, part of ASDF, that should be included in all modern implementations.

    • synchronous commands: uiop:run-program
    • asynchronous commands: uiop:launch-program

    So for example

    (uiop:run-program (list "firefox" "http:url") :output t)
    

    or

    (defparameter *shell* (uiop:launch-program "bash" :input :stream :output :stream))
    

    where you can send input and read output.

    They are more explained here: https://lispcookbook.github.io/cl-cookbook/os.html#running-external-programs

    trivial-shell is deprecated and replaced by inferior-shell, which internally uses the portable uiop's run-program (synchronous), so we can use just that.

提交回复
热议问题