要将外部进程调用clojure.java.shell/sh的标准输出路由到实际的标准输出,可以使用with-out-str函数将标准输出重定向到一个字符串中,并在外部进程调用完成后将字符串打印到实际的标准输出。以下是一个示例代码:
(require '[clojure.java.shell :refer [sh]])
(require '[clojure.string :as str])
(defn sh-with-output [cmd]
(let [output (with-out-str (sh cmd))]
(println output)))
(sh-with-output "ls -la")
在上面的代码中,我们定义了一个sh-with-output函数,它接受一个命令字符串作为参数,并使用with-out-str函数将标准输出重定向到一个字符串中。然后,我们通过调用sh函数来执行外部命令,并将标准输出结果存储在output变量中。最后,我们使用println函数将output打印到实际的标准输出。
在这个示例中,我们调用了sh函数来执行ls -la命令,并将输出结果打印到实际的标准输出。
希望对你有所帮助!