Open panzi opened 3 months ago
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:
\n
.*
.env
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:
}
https://github.com/compose-spec/compose-go/blob/9d0d133e13d0955e27520c6317d08822b7c5de5f/template/template.go#L31
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.)
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:You get this error mesage:
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:https://github.com/compose-spec/compose-go/blob/9d0d133e13d0955e27520c6317d08822b7c5de5f/template/template.go#L31
To this:
(I don't know if there is another way to match anything, including a
\n
, in Go.)