Dotenv: Allow for optional `export` at the beginning of each line

Created on 14 Jul 2017  路  4Comments  路  Source: motdotla/dotenv

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

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 export will work. You may find it to be a better fit for your use case.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tikotzky picture tikotzky  路  4Comments

mattcdavis1 picture mattcdavis1  路  5Comments

Vandivier picture Vandivier  路  3Comments

Quocnamit picture Quocnamit  路  3Comments

shellscape picture shellscape  路  3Comments