ANN: clojure.java.shell2 drop in replacement for clojure.java.shell

359 views
Skip to first unread message

Marc Limotte

unread,
Jun 25, 2013, 11:57:58 AM6/25/13
to clo...@googlegroups.com
I'm announcing java.shell2.  It is backward compatible with clojure.java.shell.  This is a Clojure library to facilitate launching of sub-processes and piping (streaming) data.

Features
- A declarative syntax for defining new processes to specify input, output, encoding, and other behavior
- Handling for common use-cases (i.e. pass stdout/err of the process to the same destination as the parent, merge stderr of the process to stdout, output directly to a File, etc)
- The pipe macro handles all the complexity of managing multipe streams and threads for streaming data through multiple processes and clojure functions.
- Backward compatible with existing code that uses clojure.java.shell (i.e. a drop-in replacement)

Shell has additional predicates like :pass, which will connect STDOUT or STDERR of the process to the STDOUT/ERR of the parent JVM.

(sh "wc" "-l" :in input :err :pass :out (io/file "/tmp/foo"))

So the above form reads input (which can be a file, stream, string, etc), forwards the output to a file and redirects STDERR to STDERR of the JVM.

And here's an example of a pipe:

(pipe
  (sh "cat" :in input)
  my-filter-fn    ;A clojure function -- data is streamed
  (sh "wc" "-l"))

This library was developed at The Climate Corporation, so a big thank you to them for allowing me to open source this code under an EPL license.  Climate Corp has one of the largest Clojure development teams.  We are an established startup with offices in San Francisco and Seattle; and are currently hiring full-time Clojure developers, data scientists, product managers and more.

See the README for more details and many examples in the unit tests.  

I know there are other shell libraries for Clojure.  My main motivation is that I wanted something closer to the clojure.java.shell api.

Marc Limotte


Max Gonzih

unread,
May 18, 2015, 2:55:26 PM5/18/15
to clo...@googlegroups.com
Hello,

I just found about this nice improvement over default java.shell provided by clojure stdlib.
What is current status of this project? Is it still useful or maybe there are alternatives?
Does it support latest clojure versions (1.6 or even maybe 1.7-beta)?

Thanks!

Marc Limotte

unread,
May 18, 2015, 3:25:50 PM5/18/15
to clo...@googlegroups.com
Hi Max.

I'm not actively doing any work on it.  Mainly because there are no requests for changes.  It's pretty straight-forward.  I haven't tested it with later versions of Clojure, but I'm not aware of any breaking changes, so I would expect it to work.

There are some alternatives, e.g. https://github.com/Raynes/conch

marc


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Max Gonzih

unread,
May 19, 2015, 3:51:58 AM5/19/15
to clo...@googlegroups.com
Ok, thank you for your reply. I will give it a try then soon on one of my pet projects! Thanks!
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/hS4T84fctqk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages