Skip to content

Instantly share code, notes, and snippets.

@rotaliator
Last active March 17, 2022 20:08
Show Gist options
  • Save rotaliator/a4f71d09eec904eb22e86c0bde2ca128 to your computer and use it in GitHub Desktop.
Save rotaliator/a4f71d09eec904eb22e86c0bde2ca128 to your computer and use it in GitHub Desktop.
Windows and Linux sh in clojure
(require '[clojure.string :as str])
(require '[clojure.java.shell :refer [sh]])
(defn shell-linux [cmd]
(sh "sh" "-c" cmd))
(defn shell-windows [cmd]
(sh "cmd" "/C" cmd))
(def shell
(if (str/includes? (str/lower-case (System/getProperty "os.name")) "windows")
shell-windows
shell-linux))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment