Fork me on GitHub
#clojure-nl
<
2020-03-13
>
Mno08:03:20

mornin' working from home because government recommendations

Kevin09:03:45

Morning 👋 We're having a "work from home" test today

skuro12:03:04

@borkdude can I export new env vars using babashka?

skuro12:03:06

not useful for me anyways

borkdude12:03:08

@skuro you cannot export env vars from within a process to the next process afaik

skuro12:03:39

the very sense of exporting an env var is to make it visible to sub processes

skuro12:03:03

so if you mean "sibling process" when you say next process then you are right

borkdude12:03:45

@skuro right. passing env vars to a subprocess can be done like this:

$ bb '(shell/sh "bb" "-e" "(System/getenv \"FOOBAR\")" :env {"FOOBAR" "123"})'
{:exit 0, :out "\"123\"\n", :err ""}

borkdude12:03:16

so here I invoke bb as a sub-process which reads the env var FOOBAR, which I pass from the parent process

borkdude12:03:32

@skuro If you need anything beyond clojure.java.shell you can drop down to ProcessBuilder. e.g. like here: https://github.com/borkdude/babashka.curl/blob/3104d234a63fca71f0d3557c5d3dc23f4fbc294f/src/babashka/curl.clj#L24 ProcessBuilder also accepts env vars.

skuro12:03:14

yep I spotted that