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

How should I store values with dollar signs ($)...(escaped, quoted)? #214

Closed
timkelty opened this issue Sep 29, 2015 · 4 comments
Closed

Comments

@timkelty
Copy link

I have a .env file that is being parsed by both PHP and node Node implementations.

I'm asking here in the canonical repo, as this is more of a best practice question.

I have values that have literal dollar signs in them:

DB_PASS=DgaH$a43

Should I be quoting that, or escaping the dollar?
If I escape the dollar in my .env file, will I need to unescape it when i use it?

So I guess it boils down to - should I be escaping the dollar in my .env file, or when I get the value with PHP or Node or whatever?

@bkeepers
Copy link
Owner

The Ruby implementation of dotenv follows follows bash as closely as possible, which means $ needs to be escaped unless it is in single quotes. These are all valid:

DB_PASS=DgaH\$a43
DB_PASS="DgaH\$a43"
DB_PASS='DgaH$a43'

The value in ruby will be unescaped.

@timkelty
Copy link
Author

The value in ruby will be unescaped.

Thanks! That's what I was looking for.

@tasaif
Copy link

tasaif commented Dec 8, 2017

This isn't working for me. The name of the environment variable is picked up but its value is an empty string.

@tasaif
Copy link

tasaif commented Dec 8, 2017

nvm I was accidentally using dot_env? Why is this package allowed to exist?

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

3 participants