babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
maxp 2021-06-04T04:49:28.393600Z

I'm trying to use bb tasks as Makefile replacement. How to import environment variables? like set -a ;; source .../myenv ;; ...

maxp 2021-06-04T05:11:34.393900Z

now I do

:tasks
  {
    dev (shell "bash -c 'set -ae ; source VARS ; source ${DEV_ENV} && clojure -M:dev:nrepl'")
  }

maxp 2021-06-04T05:11:55.394300Z

is there more elegant way?

mike_ananev 2021-06-04T05:53:58.398800Z

@maxp Hi! In babashka I use the following method: 1. I can set and control any value by means of config files in EDN-format. I don't need ENV vars in most cases. See example https://github.com/redstarssystems/rssyslib/blob/4de3fa36fcf6fa629f4340bbefacd4842bddc606/bb.edn#L14 2. When I need to set ENV vars for subprocess I do it like this https://github.com/redstarssystems/rssyslib/blob/4de3fa36fcf6fa629f4340bbefacd4842bddc606/bb.edn#L46 3. To read ENV vars I use cprop function from-env

maxp 2021-06-04T05:56:01.399400Z

cprop in Babashka - it's so good! ^)

maxp 2021-06-04T05:58:31.400400Z

I prepare myself to switch from shell based scripts.

👍 1
borkdude 2021-06-04T07:18:27.401400Z

@mike1452 you don't have to use env to pass environment variables to a child process, you can use (shell {:extra-env {"FOO" "BAR"}} ....)

👍 1
borkdude 2021-06-05T07:04:42.407400Z

It says it takes the same options as babashka.process/process :-)

👍 1
maxp 2021-06-04T07:24:34.401600Z

That's what I need. is it documented?

borkdude 2021-06-04T07:59:23.401800Z

Documented here: https://book.babashka.org/#_shell

Helins 2021-06-04T10:43:16.403100Z

Can something similar be achieved before launching something with (clojure ...) ? (setting env vars)

borkdude 2021-06-04T10:43:36.403300Z

yes

borkdude 2021-06-04T10:43:40.403500Z

exactly the same

Helins 2021-06-04T10:44:47.403800Z

Damn, I can't even find a single reason for complaining about BB

😆 1
Helins 2021-06-04T11:01:02.405300Z

By the way, I did write very simple caching for BB on CircleCI, it's not particularly smart but it works and allow for upgrading version: https://gist.github.com/helins/59e3abfc96f7a641d608a314fb6b8665

👍 1
borkdude 2021-06-04T11:02:48.405500Z

what does the backslash before curl and tar mean?

Helins 2021-06-04T11:07:06.405700Z

Simply breaks the line, otherwise it was sometimes misbehaving in my terminal. But you could simplify it to something like this it seems: [ -f "bb.tar.gz" ] && tar -xzvf bb.tar.gz I forgot pretty much everything I knew about Bash...

borkdude 2021-06-04T11:08:58.406Z

kind of the point of bb

maxp 2021-06-04T23:51:26.406400Z

Could not find any "extra-env" in the hole page :(