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
Best Answer
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.