foreman
can read .env files and set environment variables from the contents, and then run a program
e.g. foreman run -e vars.env myprogram
...but it does a lot of other things (and is primarily concerned with starting things using its Procfile format).
Is there a simpler (Linux/Unix) tool that's just focussed on reading .env files and executing a command with the new environment?
Example environment file (from http://ddollar.github.io/foreman/#ENVIRONMENT ):
FOO=bar
BAZ=qux
You can source the environment file in the active shell and run the program:
The
-a
switch exports all variables, so that they are available to the program.Another alternative is
envdir
:I tried
source .env
and it worked like a charm. Unfortunately, none of the other solutions posted here worked for me.This works:
but obviously doesn't check the format of the
.env
file for correctness, which a utility program would do.