Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for optional export at the beginning of each line #213

Closed
DesignByOnyx opened this issue Jul 13, 2017 · 5 comments
Closed

Allow for optional export at the beginning of each line #213

DesignByOnyx opened this issue Jul 13, 2017 · 5 comments

Comments

@DesignByOnyx
Copy link

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
@maxbeatty
Copy link
Contributor

Discussion in #112 and #118 are still valid to me. Check out dotenv-export

@sneakertack
Copy link

@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.

@metaskills
Copy link

Thanks for the nvar recommendation.

@coolaj86
Copy link

coolaj86 commented Nov 1, 2020

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: #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.

@jasonkarns
Copy link

dotenv-export isn't helpful in the minimal case.

Scenario: We're using create-react-app, and therefore dotenv implicitly. We have .env files. In our circle and build environments, we need the same env vars exported for things outside of node. In other words, we just want to be able to . .env (as we do in our rails app).

dotenv-export doesn't make this possible because it requires that we use it as the CLI. Which means we now need to install node and dotenv-export into containers that otherwise don't need node at all.

The frustration that we (and clearly many others #112 (comment)) are experiencing is that dotenv doesn't support the "conventional" .env file format that would make it interoperable with a host of other tooling (direnv, bkeepers/dotenv, source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants