我想阅读shell命令的输出。
我想要读取的shell命令必须从特定位置运行。 (它是git log
)。
除cd
进入该位置,运行(clojure.java.shell/sh "git log")
,然后cd
返回工作目录外,有没有其他方法可以做到这一点?
我正在寻找某种(shell-at directory command)
功能。还将理解该功能的简单实现。我对Clojure的经验很少。
答案 0 :(得分:29)
clojure.java.shell/sh
支持:dir
选项来设置子流程的工作目录:
(clojure.java.shell/sh "git" "log" :dir "/path/to/some/directory")
请参阅here。