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

Export all .env variables declared at the start of a line. #38

Closed
wants to merge 1 commit into from
Closed

Export all .env variables declared at the start of a line. #38

wants to merge 1 commit into from

Conversation

marcusrbrown
Copy link

This change is in response to #28. After the .env is sourced, sed is run to extract the names of all declared variables, and these are exported. Exporting is required in order to use the variables in child processes and to remain compatible with Foreman.

Variable declarations that include whitespace at the beginning of the line aren't supported because Foreman and other utilities that parse .env files don't support them.

@devinus
Copy link
Contributor

devinus commented Jun 10, 2013

I'm not sure if I like using sed to do this. Maybe we could get a diff of the env variables before/after sourcing and then export the new ones?

@marcusrbrown
Copy link
Author

What's wrong with using sed? Thanks.

@devinus
Copy link
Contributor

devinus commented Jun 10, 2013

@igetgames It just seems incredibly fragile.

@devinus
Copy link
Contributor

devinus commented Jun 10, 2013

Regardless of what the solution is, this needs to happen.

@marcusrbrown
Copy link
Author

@devinus Understandable, although I'm using a portable syntax, and essentially the pattern Foreman is using. A few folks have confirmed that it works on various platforms, so it should at least go in now. Once it's in I'm willing to look at alternatives. I just needed it to work :)

@ryanhiebert
Copy link

I very much want this feature in soon. I don't have a problem with sed, but unfortunately, this is a bit over-broad, if I'm reading the sed correctly. It might be worth ignoring the issue for now, but since .env is essentially a dotsource shell file, it might have something like this, which both matches the sed filter, and shouldn't be exported.

MYVAR='coolthing' ./myscript

This style is something I see regularly in, for example, configure scripts, where an environment variable is set, but only command on the same line as the variable is set.

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

Successfully merging this pull request may close these issues.

None yet

3 participants