running shell commands with gnu clisp

前端 未结 4 2074
灰色年华
灰色年华 2021-01-06 08:29

I\'m trying to create a \"system\" command for clisp that works like this

(setq result (system \"pwd\"))

;;now result is equal to /my/path/here
4条回答
  •  甜味超标
    2021-01-06 09:15

    Something like this?

    Version 2:

    (defun copy-stream (in out)
       (loop for line = (read-line in nil nil)
             while line
             do (write-line line out)))
    
    (defun system (cmd)
      (with-open-stream (s1 (ext:run-program cmd :output :stream))
        (with-output-to-string (out)
          (copy-stream s1 out))))
    
    
    [6]> (system "ls")
    "#.emacs#
    Applications
    ..."
    

提交回复
热议问题