Fork me on GitHub
#tools-deps
<
2018-06-10
>
borkdude15:06:41

Cool, I needed this once too

ghadi16:06:31

I do that all the time. I like datomic ion's take on it too.

ghadi16:06:48

Sending in an edn map through an arg or stdin

gfredericks17:06:29

ironically I quickly realized that I couldn't do that in this case, because the program also took its input from stdin

gfredericks17:06:29

I guess in theory I could have arranged for the script to be prepended to the input and make sure the last form is one that does the work and then System/exits, but that sounds pretty hacky

borkdude17:06:19

@gfredericks I once asked for an option in here to provide a program with the -e option, without printing expressions.

borkdude17:06:26

Would that make sense in your case?

gfredericks17:06:47

I could've but it was a ~20 line script so I felt weird putting that in an arg

borkdude17:06:03

put it in a variable.

dominicm17:06:18

clojure -e <<EOF
  (println "ta-da")
EOF

dominicm17:06:25

heredoc can be pretty useful

dominicm17:06:05

(apparently that doesn't work)

borkdude17:06:25

Borkdude@borkdude /tmp $ echo '(println "hello")' > hello.clj
Borkdude@borkdude /tmp $ clj -e "$(cat hello.clj)"
hello
Borkdude@borkdude /tmp $

borkdude17:06:48

But then again, you could just do clj hello.clj 🙂

gfredericks17:06:43

I'm not a bash lawyer yet, but I got the distinct impression yesterday that <<EOF goes to stdin

dominicm17:06:31

clojure -e "$(cat << 'FOO'
  (println "ta-da")
FOO
)"
You're right, I've just got on a journey learning that 🙂

gfredericks17:06:28

I've been learning some bash recently. Weirdest thing so far is the <> redirection operator.

dominicm17:06:49

what does that do?

gfredericks20:06:12

same as < except it makes stdin writable