planck 2017-01-05

you can do this even simpler

sh accepts a :in argument

line 27 of that gist.

which would translate into something like

#!/usr/bin/env planck
(ns panpdf.core
  (:require [planck.shell :refer [sh]]))
(def s "\"#foo\nbar\"")
(sh "pandoc -o fbb.html" :in s)

from the example above.

👍 2

ooooooh good catch, thanks @slipset

Hey @mfikes --- do you have a moment to be bugged with a planck question? Or any other wise people in the room 🙂... Does planck.shell/sh support piping? I'm trying to achieve the equivalent of echo "#foo\nbar" | pandoc -o fbb.html in shell (which just generates a html file from a markdown string). Tried the following, which just silently fails:

#!/usr/bin/env planck
(ns panpdf.core
  (:require [planck.shell :refer [sh]]))
(def s "#foo\nbar")
(sh "echo" s "|" "pandoc" "-o" "fbb.html")
looking at the return, I seem to be getting:
{:exit 0, :out #foo
bar | pandoc -o fbb.html
, :err }

also tried it with some extra escaped quotes around the string, i.e., (def s "\"#foo\nbar\"") -- still no dice

Well, piping is an aspect of a shell itself. The sh function just launches an executable with arguments. I suspect the same would also fail with clojure.java.shell/sh

that makes sense...

I guess there's no avoiding shell scripts here then. oh well! thanks 🙂

The only thing I can think to try would be to spit the string to a temp file and then have pandoc operate on the file

which might be worth it. Oh hey, another great use for UUIDs!

muchos gracias!

It might be possible to launch bash and tell it to pipe via some -e construct. Hrm

iinteresting.

bash -c seems to execute from a string...

Ahh yeah. Then maybe the string can construct a pipe

1

#!/usr/bin/env planck
(ns panpdf.core
  (:require [planck.shell :refer [sh]]))
(def s "\"#foo\nbar\"")
(sh "bash" "-c" (str "echo " s " | pandoc -o fbb.html"))
works! bam!

that's awesome

and now I don't have to write any shell or any haskell to manipulate text before sending it to pandoc. bwahahahaha