-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Require braces to be present for environment variable expansion #1304
Conversation
// ${} is all ASCII, so bytes are fine for this operation. | ||
i := 0 | ||
for j := 0; j < len(s); j++ { | ||
if s[j] == '$' && j+2 < len(s) && s[j+1] == '{' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only line that was changed from the os.Expand
function.
{"x${Z:D}", "xD"}, | ||
{"x${Z:A B C D}", "xA B C D"}, // Spaces are allowed in the default. | ||
{"x${Z:}", "x"}, | ||
|
||
// Defaults don't work unless braces are used. | ||
{"x$y:D", "xy:D"}, | ||
// Un-matched braces are swallowed by the Go os.Expand function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unfortunately increases the chance of it showing up accidentally, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it does. I'll see about modify their code to remove this behavior. I didn't realize it did this until I started reading the code.
Merging this as is, to have it in alpha1. Remaining comments can be addressed in other PRs. |
- Variable expressions cannot be split across newlines. - Unterminated variable expressions cause errors rather than silently swallowing characters. - Added an escape sequence for using a literal '${' value. Follow up to issue elastic#1304
- Variable expressions cannot be split across newlines. - Unterminated variable expressions cause errors rather than silently swallowing characters. - Added an escape sequence for using a literal '${' value. Follow up to issue #1304
The docs were updated in #1290.