Last active
March 17, 2022 20:08
-
-
Save rotaliator/a4f71d09eec904eb22e86c0bde2ca128 to your computer and use it in GitHub Desktop.
Windows and Linux sh in clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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