Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Clojure by

I've been using clojure.java.process from the Clojure 1.12 RCs a lot and it's great having that functionality built right in to clojure.

I frequently find myself wanting a fully interactive process that blocks until exit. For example

(require '[clojure.java.process :as p])
(let [p (p/start
            {:in  :inherit
             :out :inherit
             :err :inherit}
            "bash")]
    @(p/exit-ref p))

Having your repl become a bash shell is an extreme (but often useful) example. More frequently you might want to just call a script that has a yes or no prompt. During development and repl usage it's also a convenient default, in cases you hit some user input prompt you didn't expect and can now just answer in the repl.

Could it be worth it to add some means to support this to the clojure.java.process namespace?

Related:

Of course this I could easily use my own helper function for this or just use babashka.process instead. But I am contending that having such usage conveniently supported out of the box perhaps might get a lot of "bang for the buck".

A counterpoint is that this is one of numerous things that could be added to that namespace. There are tons of ways people might want to work with processes and clearly clojure.java.process shouldn't try to maximize convenience for every single one of them.

by
This seems pretty straightforward code -- and you could put a helper function in you user.clj file -- so it's not clear to me what you're actually asking for as a change to Clojure core itself?

1 Answer

0 votes
by
selected by
 
Best answer

Might be useful at some point, but I'm happy to collect interest here to see if the pattern is prevalent enough to warrant addition.

...