Skip to content

Commit f02e024

Browse files
committed
discard
1 parent 2064066 commit f02e024

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/babashka/process.cljc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@
219219
:escape default-escape
220220
:program-resolver default-program-resolver})
221221

222-
(defn- normalize-opts [{:keys [:out :err :in :inherit] :as opts}]
222+
(def ^java.io.File null-file
223+
(delay (io/file (if windows?
224+
"NUL"
225+
"/dev/null"))))
226+
227+
(defn- normalize-opts [{:keys [out err in inherit] :as opts}]
223228
(cond-> opts
224229
(and inherit (not out))
225230
(-> (assoc :out :inherit))
@@ -265,12 +270,18 @@
265270
:inherit (.redirectOutput pb ProcessBuilder$Redirect/INHERIT)
266271
:write (.redirectOutput pb (ProcessBuilder$Redirect/to (io/file (str out-file))))
267272
:append (.redirectOutput pb (ProcessBuilder$Redirect/appendTo (io/file (str out-file))))
273+
:discard (.redirectOutput pb (if-before-jdk8
274+
(ProcessBuilder$Redirect/to @null-file)
275+
ProcessBuilder$Redirect/DISCARD))
268276
nil)
269277
(case err
270278
:out (.redirectErrorStream pb true)
271279
:inherit (.redirectError pb ProcessBuilder$Redirect/INHERIT)
272280
:write (.redirectError pb (ProcessBuilder$Redirect/to (io/file (str err-file))))
273281
:append (.redirectError pb (ProcessBuilder$Redirect/appendTo (io/file (str err-file))))
282+
:discard (.redirectOutput pb (if-before-jdk8
283+
(ProcessBuilder$Redirect/to @null-file)
284+
ProcessBuilder$Redirect/DISCARD))
274285
nil)
275286
(case in
276287
:inherit (.redirectInput pb ProcessBuilder$Redirect/INHERIT)

0 commit comments

Comments
 (0)