Skip to content

Instantly share code, notes, and snippets.

@whamtet
Last active May 17, 2024 06:46
Show Gist options
  • Save whamtet/6c8c68719416a20163c628db718aaf1d to your computer and use it in GitHub Desktop.
Save whamtet/6c8c68719416a20163c628db718aaf1d to your computer and use it in GitHub Desktop.
(defn sh
[dir & args]
(let [proc (.exec (Runtime/getRuntime)
^"[Ljava.lang.String;" (into-array args)
(make-array String 0)
(io/as-file dir))]
(with-open [stdout (.getInputStream proc)
stderr (.getErrorStream proc)]
(future (io/copy stdout *out*))
(future (io/copy stderr *err*))
(.waitFor proc) ;; important!
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment