running shell commands with gnu clisp

前端 未结 4 2050
灰色年华
灰色年华 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:09

    Per the CLISP documentation on run-program, the :output argument should be one of

    • :terminal - writes to the terminal
    • :stream - creates and returns an input stream from which you can read
    • a pathname designator - writes to the designated file
    • nil - ignores the output

    If you're looking to collect the output into a string, you'll have to use a read-write copying loop to transfer the data from the returned stream to a string. You already have with-output-to-string in play, per Rainer's suggestion, but instead of providing that output stream to run-program, you'll need to write to it yourself, copying the data from the input stream returned by run-program.

提交回复
热议问题