我想读取 shell 命令的输出。
我要读取的 shell 命令必须从特定位置运行。 (它是 git log
)。
除了 cd
之外,还有其他好的方法可以做到这一点吗?进入位置,运行 (clojure.java.shell/sh "git log")
,然后 cd
回到工作目录?
我正在寻找某种 (shell-at directory command)
功能。此功能的简单实现也将受到赞赏。我对 Clojure 的经验很少。
请您参考如下方法:
clojure.java.shell/sh
支持 :dir
设置子进程的工作目录的选项:
(clojure.java.shell/sh "git" "log" :dir "/path/to/some/directory")
见 here .