Hi, how can I get value of an env variable? I tried (planck.shell/sh "echo" "$HOME”)
, but it returns {:exit 0, :out "$HOME\n", :err “”}
.
@honzabrecka One approach would be to parse the response of the env
command.
FWIW, Planck behaves like Clojure for this use case:
user=> (clojure.java.shell/sh "echo" "$HOME")
{:exit 0, :out "$HOME\n", :err “”}
@mfikes Thanks, I’ll go that way. In clojure we have System/getenv
.
@honzabrecka See parsing code here: https://github.com/mfikes/planck/issues/165#issuecomment-159069195
It essentially supports your exact use case, resulting in
cljs.user=> (get (env.core/get-env) "HOME")
“/Users/mfikes”
Thanks. Just a note, it won’t work with variable that contains =
, eg. some base64 encoded value.
@honzabrecka Thanks! I fixed the example parsing code there for that issue.
I added a 2
to (string/split line #"=" 2)