从特定位置在Clojure中运行shell命令

时间:2012-09-06 00:04:29

标签: shell clojure

我想阅读shell命令的输出。 我想要读取的shell命令必须从特定位置运行。 (它是git log)。

cd进入该位置,运行(clojure.java.shell/sh "git log"),然后cd返回工作目录外,有没有其他方法可以做到这一点?

我正在寻找某种(shell-at directory command)功能。还将理解该功能的简单实现。我对Clojure的经验很少。

1 个答案:

答案 0 :(得分:29)

clojure.java.shell/sh支持:dir选项来设置子流程的工作目录:

(clojure.java.shell/sh "git" "log" :dir "/path/to/some/directory")

请参阅here