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

Literals with escaped interpolations work #4747

Merged
merged 3 commits into from
Jan 20, 2016
Merged

Literals with escaped interpolations work #4747

merged 3 commits into from
Jan 20, 2016

Conversation

mitchellh
Copy link
Contributor

Fixes #2909

If you had a literal with an escaped interpolation such as foo-$${bar} it was not properly turning into foo-${bar}. This fixes that.

The fix is simple: we had an optimization where if after we parsed the string for interpolations we found only a literal we assumed there was nothing and skipped it. We now check to make sure the result is also the same string and if not, we still evaluate the string.

@mitchellh
Copy link
Contributor Author

Real failing tests :( I'll look

@mitchellh
Copy link
Contributor Author

Fixed tests

@apparentlymart
Copy link
Contributor

LGTM!

Thanks for fixing this... it was messing with me just last week when I was trying to use Rundeck interpolations, which happen to use the same syntax as Terraform, and it was really bugging me why the escaping sometimes worked and sometimes didn't. Nice to see that there's a reasonable explanation for that. 😄

@phinze
Copy link
Contributor

phinze commented Jan 19, 2016

LGTM

phinze added a commit that referenced this pull request Jan 20, 2016
Literals with escaped interpolations work
@phinze phinze merged commit 911575b into master Jan 20, 2016
@phinze phinze deleted the b-escaped branch January 20, 2016 00:23
@rkul
Copy link

rkul commented Mar 1, 2016

Interpolation escaping also doesn't work for templates. If template contains $${var}, it renders into $${var}.
Simple workaround is to use replace func when rendering:
${replace(template_file.config.rendered,"$$","$")}

@ghost
Copy link

ghost commented Apr 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to escape a dollar in template variable.
4 participants