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

Parsing variables in single quoted strings. #123

Closed
ericroberts opened this issue Jul 11, 2014 · 2 comments
Closed

Parsing variables in single quoted strings. #123

ericroberts opened this issue Jul 11, 2014 · 2 comments

Comments

@ericroberts
Copy link
Contributor

I recently ran into a problem because in my .env file I was setting a password, and that password happened to have a $ in it. eg: PASSWORD='pass$word'. Although I single quoted the string, the parser is still expanding the variable, when it shouldn't be.

The correct behaviour would be to expand the variable when the string is double quoted, and to not expand the variable when the string is single quoted.

I wrote some tests that reflect the proper behaviour but I'm having some difficulty writing a solution that passes all the other tests. Any help or pointers in the right direction would be appreciated. I'm happy to keep working on a solution myself but thought I would throw it out there in case this issue is known.

Here are the tests I wrote:

it 'expands variables in double quoted strings' do
  expect(env("FOO=test\nBAR=\"quote $FOO\"")).to eql('FOO' => 'test', 'BAR' => 'quote test')
end

it 'does not expand variables in single quoted strings' do
  expect(env("BAR='quote $FOO'")).to eql('BAR' => 'quote $FOO')
end
@ericroberts
Copy link
Contributor Author

Figured it out and opened a pull request here: #124

@ericroberts
Copy link
Contributor Author

Pull request has been merged.

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

1 participant