Use safer detection of process command

This commit is contained in:
Michiel Borkent 2024-11-11 22:44:02 +01:00
parent 5ab8b3f975
commit ccebfa630f

View file

@ -1142,11 +1142,11 @@ Use bb run --help to show this help output.
(defn binary-invoked-as-jar []
(and (= "executable" (System/getProperty "org.graalvm.nativeimage.kind"))
(let [bin (-> (java.lang.ProcessHandle/current)
(when-let [bin (-> (java.lang.ProcessHandle/current)
.info
.command
.get)
fn (fs/file-name bin)]
(.orElse nil))]
(let [fn (fs/file-name bin)]
(if (= "bb" fn)
false
(if (and (fs/windows?)
@ -1155,7 +1155,7 @@ Use bb run --help to show this help output.
(when (try (with-open [_ (java.util.zip.ZipFile. (fs/file bin))])
true
(catch Exception _ false))
bin))))))
bin)))))))
(defn resolve-symbolic-link [f]
(if (and f (fs/exists? f))