On 01.11.21 13:40, 'Domenico Andreoli' via swupdate wrote:
> On Mon, Nov 01, 2021 at 12:02:54PM +0100, Stefano Babic wrote:
>> Hi Domenico,
>>
>> On 31.10.21 11:17, Domenico Andreoli wrote:
>>> Hi Stefano,
>>>
>>> Is it a priority to support spaces also in the variable names?
>>
>> Spaces in variables is high discouraged and should not be done, but it is
>> working in U-Boot:
>>
>> setenv alfa\ pluto
>> => pri
>> alfa =pluto
>>
>>> If not then it would be
>>> possible to detect the usage of the original u-boot syntax and at least
>>> warn the user.
>>
>> libubootenv is a library, not a tool. It should then raise an error if '='
>> as separator is not found.
>
> I'm not proposing to change anything in the library which, by the way,
> does not seem to enforce the presence of the '=' (that also would be more
> than enough to reject the legacy syntax).
It just skips lines when separator is not found.
>
> My concern is purely fw_setenv tool eating
The interface for a script is:
libuboot_load_file(ctx, scriptfile);
Parsing is part of the library and should not be moved outside it.
>the legacy syntax without a eye
> blink and doing something different from what the user of such syntax
> expects. Consider that U-Boot has a long history,
That is correct, but there is also a lot of big changes in ölast U-Boot
versions, such as switching to DM and DT. It is
> fw_setenv has not
> supported the '=' syntax for a very long time and many users would be
> caught by surprise.
Introducing "=" in U-Boot was done quite at the same time when
libubootenv was introduced.
> I think they would be well served by an head-up sign.
>
> So, given that spaces in the variable names are discouraged,
Discouraged but rather not forbidden, and if this should be, it should
be first done in U-Boot (but then, this becomes valid just for newer
U-Boot versions).
> it's maybe an
> idea to take advantage of that and be able to detect the legacy syntax.
>
> If you don't want to enforce a general "no spaces in the var names" (it
> would catch both the discouraged behavior and the legacy syntax), the tool
> could complain only if both the var name has spaces _and_ no '=' is found
> on the line.
It is not enough because '=' can be part of the script itself.
>
> OTOH, if you think it's better to just check for the presence of '=',
> that's absolutely fine with me!
At the moment, I think it is enough to document this without canging the
behavior.
>
>>>
>>> The idea is that "name [space] value" in the original syntax would
>>> result in an empty
>>> variable named "name [space] value" in the new one, something that we
>>> could consider
>>> not a best practice.
>>>
>>> Would you consider a patch for this?
>>
>> I think that a rule is enough, having both is still more confusing.
>
> I value simplicity and linear behaviors, avoiding surprises and unexpected
> side effects, reducing confusion. Flexibility it's not selling itself and
> not what I'm asking to add.
>
Best regards,
Stefano Babic