planck

Planck ClojureScript REPL
kauko 2017-02-17T08:16:33.000637Z

(planck.shell/with-sh-dir "." (:out (planck.shell/sh "pwd"))) works but (planck.shell/with-sh-dir "." (:out (planck.shell/sh "git log"))) gives me "launch path not accessible"

kauko 2017-02-17T08:16:42.000638Z

What's wrong?

kauko 2017-02-17T09:32:37.000639Z

Oh, I think I'm not supposed to use spaces

kauko 2017-02-17T11:37:31.000640Z

Hmm, not really about planck, but I figure there's people in this channel who could know the answer

kauko 2017-02-17T11:38:32.000641Z

I'm wondering why (sh/sh "ag" "a") doesn't work. The command runs, but exits with 1 and doesn't find anything. (sh/sh "pwd") tells me I'm in the right directory, and the ag command works fine from the command line

kauko 2017-02-17T12:47:46.000642Z

I got it, ag required a path as its third argument

mfikes 2017-02-17T12:50:43.000643Z

Cool… glad you figured it out @kauko . The planck.shell namespace is meant to mimic clojure.java.shell, so you can both use examples in the wild about using the Clojure namespace, and potential bugs in Planck (if it isn’t of high fidelity in corner cases).

kauko 2017-02-17T12:51:48.000644Z

Yeah

kauko 2017-02-17T12:52:09.000645Z

Though now I ran into the problem of piping ag's output to wc

kauko 2017-02-17T12:52:26.000646Z

Can't figure out how pipes are supposed to work with clojure.java.shell`

mfikes 2017-02-17T12:55:38.000647Z

Arg. This exact question came up before and was solved… need to find the web archive of this channel 🙂

mfikes 2017-02-17T12:56:06.000648Z

I think it involved launching a subshell and having it do the pipe operation.

mfikes 2017-02-17T12:56:35.000649Z

Like (shell/sh “sh” “-c” “some command string with pipes”)

mfikes 2017-02-17T12:57:36.000650Z

We need Planck to support https://github.com/mfikes/planck/issues/54

kauko 2017-02-17T13:07:56.000652Z

Yeah that worked, thanks 🙂

kauko 2017-02-17T13:08:16.000653Z

Is that because of java's shell integration?

kauko 2017-02-17T13:08:34.000654Z

It's a shame it works so poorly, I'd love to replace some more complicated bash scripts with clojure

kauko 2017-02-17T13:09:17.000655Z

Well, planck is clojurescript I guess

mfikes 2017-02-17T13:12:07.000657Z

@kauko Well, I believe the concept of pipes are implemented by shells (as in Bash). So, neither Planck nor clojure.java.shell can directly do anything about pipes. All they can do is launch processes. But… clojure.java.shell has a facility where you can obtain a stream for stdout and stderr (instead of strings), and with such streams you could theoretically compose them in Clojure to produce pipes. Planck doesn’t yet support the notion of returning a stream, but it probably could fairly easily.