Fork me on GitHub
#babashka
<
2021-06-04
>
maxp04:06:28

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

maxp05:06:34

now I do

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

maxp05:06:55

is there more elegant way?

mike_ananev05:06:58

@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

maxp05:06:01

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

maxp05:06:31

I prepare myself to switch from shell based scripts.

👍 1