Sometimes it is useful to export the contents of the .env file into the current terminal session so that individual scripts can be tested in isolation. The only way it is possible right now is to use a rather convoluted script to read the contents and export them:
$ export $(cat .env | grep -v ^# | xargs)
It would be nice to allow for an optional export word at the beginning of each line:
export FOO=bar
This would allow users to source their environment vars into the current bash/terminal session:
source .env
Discussion in #112 and #118 are still valid to me. Check out dotenv-export
@DesignByOnyx If this is still bugging you, I recently wrote nvar. It works mostly like dotenv, except its syntax follows Shell instead of INI, so things like export will work. You may find it to be a better fit for your use case.
Thanks for the nvar recommendation.
I'm a little confused. Isn't the point of this dotenv to follow the dotenv spec as set forth by the original dotenv?
Also, (RE: https://github.com/motdotla/dotenv/pull/118):
# valid
EXPORT=true
# valid
export EXPORT=true
# invalid: `export` is exclusively lowercase
EXPORT EXPORT=true
# ... of questionable validity: ENVs are supposed to be ALL_CAPS.
foo=bar
Although export=true doesn't make sense, I don't see why export export=true and export=true _can't_ coexist.
Most helpful comment
@DesignByOnyx If this is still bugging you, I recently wrote nvar. It works mostly like dotenv, except its syntax follows Shell instead of INI, so things like
exportwill work. You may find it to be a better fit for your use case.