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

templates cannot have default values containing new lines #653

Open
panzi opened this issue Jul 2, 2024 · 0 comments
Open

templates cannot have default values containing new lines #653

panzi opened this issue Jul 2, 2024 · 0 comments

Comments

@panzi
Copy link

panzi commented Jul 2, 2024

The default value of a variable cannot contain a new line (\n) character because .* doesn't match those. I.e. if you have this in your .env file:

FOO="${BAR:-multi
line}"

You get this error mesage:

2024/07/02 02:49:54 Invalid template: "${BAR:-multi\nline}"

This is a bit confusing, because this doesn't look like an invalid template. Because of the quotes the whole string is correctly parsed, the template has a valid name and does end with }. To fix this you need to change this regular expression:

var substitutionBraced = "[_a-z][_a-z0-9]*(?::?[-+?](.*))?"

To this:

var substitutionBraced = "[_a-z][_a-z0-9]*(?::?[-+?]((?:.|\n)*))?"

(I don't know if there is another way to match anything, including a \n, in Go.)

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