Skip to main content
 首页 » 编程设计

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

2025年02月15日22arxive

我想读取 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 .