From edf9799bddb0f541a5bf2d0f3a0c41d89fbfa699 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 13 Apr 2021 23:11:14 +0200 Subject: [PATCH 1/8] wip --- src/borkdude/deps.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/borkdude/deps.clj b/src/borkdude/deps.clj index 89684cc..de68b35 100755 --- a/src/borkdude/deps.clj +++ b/src/borkdude/deps.clj @@ -517,9 +517,9 @@ For more info, see: (let [res (shell-command (into clj-main-cmd (concat ["-m" "clojure.tools.deps.alpha.script.make-classpath2" - "--config-user" config-user - "--config-project" config-project - "--basis-file" basis-file + "--config-user" (double-quote config-user) + "--config-project" (double-quote config-project) + "--basis-file" (double-quote basis-file) "--libs-file" (double-quote libs-file) "--cp-file" (double-quote cp-file) "--jvm-file" (double-quote jvm-file) From c1ad336306f726c5929d0202e9c540d01cc7e5d3 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 13 Apr 2021 23:11:25 +0200 Subject: [PATCH 2/8] wip --- deps.bat | 6 +++--- deps.clj | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deps.bat b/deps.bat index 3cab95d..5f74496 100644 --- a/deps.bat +++ b/deps.bat @@ -523,9 +523,9 @@ For more info, see: (let [res (shell-command (into clj-main-cmd (concat ["-m" "clojure.tools.deps.alpha.script.make-classpath2" - "--config-user" config-user - "--config-project" config-project - "--basis-file" basis-file + "--config-user" (double-quote config-user) + "--config-project" (double-quote config-project) + "--basis-file" (double-quote basis-file) "--libs-file" (double-quote libs-file) "--cp-file" (double-quote cp-file) "--jvm-file" (double-quote jvm-file) diff --git a/deps.clj b/deps.clj index 8fc0ae8..9804b6b 100755 --- a/deps.clj +++ b/deps.clj @@ -517,9 +517,9 @@ For more info, see: (let [res (shell-command (into clj-main-cmd (concat ["-m" "clojure.tools.deps.alpha.script.make-classpath2" - "--config-user" config-user - "--config-project" config-project - "--basis-file" basis-file + "--config-user" (double-quote config-user) + "--config-project" (double-quote config-project) + "--basis-file" (double-quote basis-file) "--libs-file" (double-quote libs-file) "--cp-file" (double-quote cp-file) "--jvm-file" (double-quote jvm-file) From 99c3afb543eda63d7b69754a5683d93b715d129a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 13 Apr 2021 23:32:06 +0200 Subject: [PATCH 3/8] small optimization --- src/borkdude/deps.clj | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/borkdude/deps.clj b/src/borkdude/deps.clj index de68b35..e69a6a0 100755 --- a/src/borkdude/deps.clj +++ b/src/borkdude/deps.clj @@ -148,11 +148,13 @@ For more info, see: (str/lower-case) (str/includes? "windows"))) +(def win? (delay (windows?))) + (defn double-quote "Double quotes shell arguments on Windows. On other platforms it just passes through the string." [s] - (if (windows?) + (if @win? (format "\"\"%s\"\"" s) s)) @@ -178,7 +180,7 @@ For more info, see: (recur (rest paths)))))))) (defn home-dir [] - (if (windows?) + (if @win? ;; workaround for https://github.com/oracle/graal/issues/1630 (System/getenv "userprofile") (System/getProperty "user.home"))) @@ -294,7 +296,7 @@ For more info, see: s)) (defn -main [& command-line-args] - (let [windows? (windows?) + (let [windows? @win? args (loop [command-line-args (seq command-line-args) acc {:mode :repl}] (if command-line-args From bf4bf48df67fbd0932ab65021cea580d4d3230d5 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 16 Apr 2021 18:23:40 +0200 Subject: [PATCH 4/8] moar quotes --- src/borkdude/deps.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borkdude/deps.clj b/src/borkdude/deps.clj index e69a6a0..ea90c74 100755 --- a/src/borkdude/deps.clj +++ b/src/borkdude/deps.clj @@ -401,7 +401,7 @@ For more info, see: clj-main-cmd (vec (concat [java-cmd] proxy-settings - ["-Xms256m" "-classpath" tools-cp "clojure.main"])) + ["-Xms256m" "-classpath" (double-quote tools-cp) "clojure.main"])) config-dir (or (System/getenv "CLJ_CONFIG") (when-let [xdg-config-home (System/getenv "XDG_CONFIG_HOME")] From ce7f9d9db4fc498841ccbb36c510720f45ed798f Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 16 Apr 2021 18:31:49 +0200 Subject: [PATCH 5/8] rm all double quotes --- src/borkdude/deps.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borkdude/deps.clj b/src/borkdude/deps.clj index ea90c74..097e86f 100755 --- a/src/borkdude/deps.clj +++ b/src/borkdude/deps.clj @@ -155,7 +155,7 @@ For more info, see: passes through the string." [s] (if @win? - (format "\"\"%s\"\"" s) + s #_(format "\"\"%s\"\"" s) s)) (defn cksum From 9cd357d24cde91c3d4b3c2d7793f8e9bee34fbd7 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 16 Apr 2021 18:40:43 +0200 Subject: [PATCH 6/8] yolo --- src/borkdude/deps.clj | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/borkdude/deps.clj b/src/borkdude/deps.clj index 097e86f..637b310 100755 --- a/src/borkdude/deps.clj +++ b/src/borkdude/deps.clj @@ -150,14 +150,6 @@ For more info, see: (def win? (delay (windows?))) -(defn double-quote - "Double quotes shell arguments on Windows. On other platforms it just - passes through the string." - [s] - (if @win? - s #_(format "\"\"%s\"\"" s) - s)) - (defn cksum [^String s] (let [hashed (.digest (java.security.MessageDigest/getInstance "MD5") @@ -401,7 +393,7 @@ For more info, see: clj-main-cmd (vec (concat [java-cmd] proxy-settings - ["-Xms256m" "-classpath" (double-quote tools-cp) "clojure.main"])) + ["-Xms256m" "-classpath" tools-cp "clojure.main"])) config-dir (or (System/getenv "CLJ_CONFIG") (when-let [xdg-config-home (System/getenv "XDG_CONFIG_HOME")] @@ -519,13 +511,13 @@ For more info, see: (let [res (shell-command (into clj-main-cmd (concat ["-m" "clojure.tools.deps.alpha.script.make-classpath2" - "--config-user" (double-quote config-user) - "--config-project" (double-quote config-project) - "--basis-file" (double-quote basis-file) - "--libs-file" (double-quote libs-file) - "--cp-file" (double-quote cp-file) - "--jvm-file" (double-quote jvm-file) - "--main-file" (double-quote main-file)] + "--config-user" config-user + "--config-project" config-project + "--basis-file" basis-file + "--libs-file" libs-file + "--cp-file" cp-file + "--jvm-file" jvm-file + "--main-file" main-file] tools-args)) {:to-string? tree?})] (when tree? From 80ee9b7009d339e46267a4da1544667bb371f50d Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 16 Apr 2021 20:17:17 +0200 Subject: [PATCH 7/8] standard windows fix --- src/borkdude/deps.clj | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/borkdude/deps.clj b/src/borkdude/deps.clj index 637b310..59c7de2 100755 --- a/src/borkdude/deps.clj +++ b/src/borkdude/deps.clj @@ -27,6 +27,13 @@ (warn msg) (System/exit exit-code)))) +(defn windows? [] + (-> (System/getProperty "os.name") + (str/lower-case) + (str/includes? "windows"))) + +(def win? (delay (windows?))) + (defn shell-command "Executes shell command. @@ -37,6 +44,9 @@ ([args] (shell-command args nil)) ([args {:keys [:to-string?]}] (let [args (mapv str args) + args (if windows? + (mapv #(str/replace % "\"" "\\\"") args) + args) pb (cond-> (ProcessBuilder. ^java.util.List args) true (.redirectError ProcessBuilder$Redirect/INHERIT) (not to-string?) (.redirectOutput ProcessBuilder$Redirect/INHERIT) @@ -143,13 +153,6 @@ For more info, see: (print "\n ") (describe-line line)) (println "}"))) -(defn windows? [] - (-> (System/getProperty "os.name") - (str/lower-case) - (str/includes? "windows"))) - -(def win? (delay (windows?))) - (defn cksum [^String s] (let [hashed (.digest (java.security.MessageDigest/getInstance "MD5") @@ -481,9 +484,7 @@ For more info, see: (when (or stale (:pom args)) (cond-> [] (not (str/blank? (:deps-data args))) - (conj "--config-data" (if windows? - (pr-str (:deps-data args)) - (:deps-data args))) + (conj "--config-data" (:deps-data args)) (:resolve-aliases args) (conj (str "-R" (:resolve-aliases args))) (:classpath-aliases args) From 9e31b359fb63e09dfc3793fd5f2fb343977456d2 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 16 Apr 2021 20:25:08 +0200 Subject: [PATCH 8/8] yo --- src/borkdude/deps.clj | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/borkdude/deps.clj b/src/borkdude/deps.clj index 59c7de2..ed9bb33 100755 --- a/src/borkdude/deps.clj +++ b/src/borkdude/deps.clj @@ -27,13 +27,11 @@ (warn msg) (System/exit exit-code)))) -(defn windows? [] +(def windows? (-> (System/getProperty "os.name") (str/lower-case) (str/includes? "windows"))) -(def win? (delay (windows?))) - (defn shell-command "Executes shell command. @@ -175,7 +173,7 @@ For more info, see: (recur (rest paths)))))))) (defn home-dir [] - (if @win? + (if windows? ;; workaround for https://github.com/oracle/graal/issues/1630 (System/getenv "userprofile") (System/getProperty "user.home"))) @@ -291,8 +289,7 @@ For more info, see: s)) (defn -main [& command-line-args] - (let [windows? @win? - args (loop [command-line-args (seq command-line-args) + (let [args (loop [command-line-args (seq command-line-args) acc {:mode :repl}] (if command-line-args (let [arg (first command-line-args) @@ -510,16 +507,16 @@ For more info, see: (when (:verbose args) (warn "Refreshing classpath")) (let [res (shell-command (into clj-main-cmd - (concat - ["-m" "clojure.tools.deps.alpha.script.make-classpath2" - "--config-user" config-user - "--config-project" config-project - "--basis-file" basis-file - "--libs-file" libs-file - "--cp-file" cp-file - "--jvm-file" jvm-file - "--main-file" main-file] - tools-args)) + (concat + ["-m" "clojure.tools.deps.alpha.script.make-classpath2" + "--config-user" config-user + "--config-project" config-project + "--basis-file" basis-file + "--libs-file" libs-file + "--cp-file" cp-file + "--jvm-file" jvm-file + "--main-file" main-file] + tools-args)) {:to-string? tree?})] (when tree? (print res) (flush))))