Fork me on GitHub

Is there a way to set env vars for tasks? I saw, so guessing not, but maybe there's a workaround?


@alex.sheluchin you can set env vars for shell and clojure, both with (f {:extra-env {"FOO" "BAR"}} ...)


@U04V15CAJ what am I doing wrong here?

foo (shell {:extra-env {:FOO "BAR"}}
           "echo $FOO")             
$ bb foo
I tried with both "FOO" and :FOO and got the same result, like it's not performing the expansion. I tried the keyword version because of this example in the bb/process readme:
user=> (-> (process '[sh -c "echo $FOO"] {:env {:FOO "BAR"}}) :out slurp)


echo $FOO
is bash syntax.


Ah, okay, I was confused in thinking bash syntax is okay there. Either "printenv FOO" or pass the command to the shell with -c. I'm not familiar with Runtime.exec() - didn't quite understand its execution context. Thanks @U04V15CAJ.


This uses ProcessBuilder, not Runtime.exec, but it's similar. There is nothing bash specific in this since it works cross platform


That makes sense seeing as clojure and shell both return a bb/process, which is a wrapper for ProcessBuilder. I think it's a little unclear because shell returns a process, and process has sh, but not shell, but there's also which has a sh and they all kinda perform.. just about the same thing, but not quite. There's a lot of name overloading going on, which I suppose is intentional to make things familiar, but still makes my brain 🤯 a little 🙂 Just my impression as someone fairly new to this machinery. I don't know if the docs could clarify this for a newbie like me. But for what it's worth, I did search for "environment variable" and similar terms in the book and couldn't find what I was looking for. Maybe it's common enough of an operation that it should get a ctrl+f friendly mention? Thanks for the help @U04V15CAJ. Just wanted to provide some feedback. Appreciate your work 🙏


@alex.sheluchin Yes, you are absolutely right and this is on my TODO list, but feel free to make a PR to the book if you want to have it in there sooner :)

👍 1

Thank you for sponsoring!


@U011NGC5FFY do you mean documentation on setting env vars? I think I added a blurb when this came up. Does that cover it?


no, on the fact that shell is not a bash shell - so it does not do expansion + example on how to do expansion.


Babashka is open to pull requests from the community if you're feeling up to it.

👍 1

If you think docs should be improved, please create PRs and/or issues


yeah thanks. I learned to ask first. Not all my ideas are great.Neither all people open to accept them, good or not.

👍 1