Fork me on GitHub
#tools-deps
<
2018-09-09
>
gfredericks11:09:31

I figured it out!

#!/usr/bin/env bash

":"; DEPS=\
'{:deps
  {org.apache.commons/commons-compress {:mvn/version "1.17"}}}'
":"; exec clojure -Sdeps "$DEPS" "$0"

rickmoynihan13:09:34

Neat. I’ve had a need for something like this this morning. Have been meaning to ask why clojure doesn’t barf on the #!/usr/bin/env bash?

rickmoynihan13:09:33

(read-string "#!/usr/bin/env bash") blows up… but clojure seems to somehow let it through…

gfredericks13:09:56

#! is indistinguishable from ; AFAIK your read-string call fails with ; as well, because there's nothing for it to return -- add a second line with a valid form and both will work

rickmoynihan13:09:25

Yeah scroll down #tools-deps 🙂

rickmoynihan13:09:52

not at all; thanks for answering 🙂

gfredericks11:09:52

☝️ that seems sufficient to let you keep your deps in the clojure-syntax part of the file

gfredericks12:09:46

also an advantage of not putting clojure in the shebang is that you don't have to give the fully qualified path to it

gfredericks12:09:37

pro-tip: if you ever have to use a lib that contains a ' in its version string (which would threaten the bash quotation), use \u0027 instead

dominicm12:09:59

You can use a quote for a version?

gfredericks12:09:10

probably

{:mvn/version "12.43.01'-sure"}
I mean I haven't tried it

dottedmag12:09:47

{haskell/haskell {:mvn/version "'"}

pesterhazy15:09:50

Weird and wonderful