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 [] (defn binary-invoked-as-jar []
(and (= "executable" (System/getProperty "org.graalvm.nativeimage.kind")) (and (= "executable" (System/getProperty "org.graalvm.nativeimage.kind"))
(let [bin (-> (java.lang.ProcessHandle/current) (when-let [bin (-> (java.lang.ProcessHandle/current)
.info .info
.command .command
.get) (.orElse nil))]
fn (fs/file-name bin)] (let [fn (fs/file-name bin)]
(if (= "bb" fn) (if (= "bb" fn)
false false
(if (and (fs/windows?) (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))]) (when (try (with-open [_ (java.util.zip.ZipFile. (fs/file bin))])
true true
(catch Exception _ false)) (catch Exception _ false))
bin)))))) bin)))))))
(defn resolve-symbolic-link [f] (defn resolve-symbolic-link [f]
(if (and f (fs/exists? f)) (if (and f (fs/exists? f))