如何在史莱姆中获取外壳函数的输出?



在 REPL 中,我们可以正常获取它的输出:

(shell "head -3 ~/misc.lisp")
(asdf:make-build 'stumpwm :type :program :monolithic t
             :move-here "."
             :name-suffix ""

然而,我们从粘液中的(shell "head -3 ~/misc.lisp")中得到零。

真诚地!

我不知道

你使用的是哪个Lisp实现,但通常你应该需要一个包来运行shell命令,如下所示:

  • 琐碎的外壳
  • 下壳
  • Clesh(建立在琐碎的外壳之上)

使用 #'run-shell-command 而不是 shell:

(let ((str (ext:run-shell-command cmd :output :stream)))
    (loop  for line = (read-line str  nil)
        until (null line)
        do (print line)))

它现在有效。

最新更新