
Hi Marek,
On Thu, 21 Oct 2021 at 07:28, Marek BehĂșn marek.behun@nic.cz wrote:
On Thu, 21 Oct 2021 15:25:37 +0200 Marek BehĂșn marek.behun@nic.cz wrote:
Hello,
On Thu, 21 Oct 2021 15:06:51 +0200 Wolfgang Denk wd@denx.de wrote:
I confirm that '+=' looks better. But '+=" is technically broken.
a bit of my opinion: I think =+ will confuse far more people than + as last character of var name working weirdly. But I also think that + should be supported as last character. Therefore I propose backslash escaping in variable name, i.e. var+=value appends value to var, while var+=value sets variable with name "var+"
My first preference is to disallow + at the end of an end var. Perhaps we can start printing a warning if people do it, for a few releases.
My distance second preference is what Marek has here, using a backslash to escape the + character.
As for =+ ...while I can see how people might parse it (we are setting the var equal to what it has with an appending string) I think it is a terrible idea as it is just not what people expect. Also, putting the + after the = places (similarly unlikely) restrictions on the expression.
The current format is basically the same as 'print'. So if I can't have the first preference, we could ensure that it prints a \ in the case that the var ends with +
Marek
Also, I think that it would be better if spaces and tabs were allowed to indent the .env file, i.e.
var_a = 3 var_bcd = 7
should set "var_a" to "3", "var_bcd" to "7".
If special character are needed in either name or value, they could be escaped and/or quoted.
They are allowed in the value but are reduced to a single space in the front. We need this for multi-line strings (but I'm a bit worried about it).
We could update it to skip any leading space after the = I think.
I don't like spaces before the = though. It doesn't match the 'print' output (which has no space) and it is confusing:
fred=echo something; if [ a == b ]; then fi
We may well have things like this if we try automatic conversion (I haven't looked though).
I think we need strict rules so it is easy for people to get exactly the env they want.
Regards, Simon