All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Wolfgang Denk <wd@denx.de>
Cc: "Simon Glass" <sjg@chromium.org>,
	"Marek Behún" <marek.behun@nic.cz>,
	"U-Boot Mailing List" <u-boot@lists.denx.de>,
	"Rasmus Villemoes" <rasmus.villemoes@prevas.dk>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Joe Hershberger" <joe.hershberger@ni.com>
Subject: Re: [PATCH v9 3/7] env: Allow U-Boot scripts to be placed in a .env file
Date: Fri, 22 Oct 2021 10:50:12 -0400	[thread overview]
Message-ID: <20211022145012.GH3577824@bill-the-cat> (raw)
In-Reply-To: <3763165.1634890015@gemini.denx.de>

[-- Attachment #1: Type: text/plain, Size: 4032 bytes --]

On Fri, Oct 22, 2021 at 10:06:55AM +0200, Wolfgang Denk wrote:
> Dear Simon,
> 
> In message <CAPnjgZ1BuAJC6Vhp06HrifU9jZqbOEuC+zRauV1DH3rY1qZp3Q@mail.gmail.com> you wrote:
> >
> > > > 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.
> 
> This might seem to be a harmless change, but it is actually a
> fundamental one.  And it breaks backward compatiility.  And all this
> without need, as a list of alternatives have been suggested.
> 
> > My distance second preference is what Marek has here, using a
> > backslash to escape the + character.
> 
> Actually this has the same problem, as the backslash is also a legal
> character in a variable name:
> 
> 	=> setenv foo\\+ bar
> 	=> printenv foo\\+  
> 	foo\+=bar
> 
> 
> Yes, it was probably not a good idea not to restrict the allowed
> character set when I implemented this stuff 21 years ago, but then
> code size was critical - we had U-Boot running from 128 kB EPROM
> (you remember these huge chips which were erased under UV light?).
> 
> The fact is, '=' and NUL are the only characters that cannot be used
> in a variable name.
> 
> 
> > 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.
> 
> What do people expect? This is a totally new feature, so people will
> use what they find in the documentation and in example code.
> 
> > Also, putting the
> > + after the = places (similarly unlikely) restrictions on the
> > expression.
> 
> There is a fundamental difference here.
> 
> For the '+=' case, there is no way to escape the '+', as all
> commonly used escapes are valid characters in the variable name,
> too.
> 
> With '=+', the '=' defines where the variable name ends, and from
> here you can define your own rules as where the value part begins -
> this is just a matter how you implement your parser.
> 
> > 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 +
> 
> But '\' is a legal character in the variable name, too. Anything but
> '=' and NUL is a legal char. And this makes escaping impossible:
> 
> 	=> setenv \'foo\\-\' foobar
> 	=> printenv \'foo\\-\'
> 	'foo\-'=foobar
> 
> > > 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).
> 
> You mean this automatically insert a newline between parts? ugh...
> I didn't realize this. Did I miss it in the documentation?
> 
> > We could update it to skip any leading space after the = I think.
> 
> So what if you need a leading space?
> 
> 
> > I don't like spaces before the = though. It doesn't match the 'print'
> > output (which has no space) and it is confusing:
> 
> env print also does not add any spaces after the '='.
> 
> > I think we need strict rules so it is easy for people to get exactly
> > the env they want.
> 
> Strict rules, proper documentation, and a set of examples.

And sanity and restrictions introduced to our environment variables.
The amount of "fun" things that were allowed by disallowing only NUL and
= from names, and also allowing us to stay crazy tiny are just not
relevant to where we are now.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  parent reply	other threads:[~2021-10-22 14:50 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 22:44 [PATCH v9 0/7] env: Allow environment in text files Simon Glass
2021-10-19 22:44 ` [PATCH v9 1/7] sandbox: Drop distro_boot Simon Glass
2021-10-19 22:44 ` [PATCH v9 2/7] doc: Move environment documentation to rST Simon Glass
2021-10-20  6:38   ` Heinrich Schuchardt
2021-10-22  3:05     ` Simon Glass
2021-10-19 22:44 ` [PATCH v9 3/7] env: Allow U-Boot scripts to be placed in a .env file Simon Glass
2021-10-21  9:50   ` Wolfgang Denk
2021-10-21 12:23     ` Tom Rini
2021-10-21 13:06       ` Wolfgang Denk
2021-10-21 13:25         ` Marek Behún
2021-10-21 13:28           ` Marek Behún
2021-10-21 15:12             ` Wolfgang Denk
2021-10-21 15:18               ` Tom Rini
2021-10-21 15:59             ` Simon Glass
2021-10-21 16:03               ` Tom Rini
2021-10-21 16:51                 ` Simon Glass
2021-10-22  6:40                 ` Rasmus Villemoes
2021-10-24 19:54                   ` Simon Glass
2021-10-25  7:06                     ` Rasmus Villemoes
2021-10-25 15:18                       ` Simon Glass
2021-10-25 19:52                         ` Rasmus Villemoes
2021-10-26 10:15                         ` Wolfgang Denk
2021-10-28 14:18                           ` Simon Glass
2021-10-22  8:08                 ` Wolfgang Denk
2021-10-22 14:47                   ` Tom Rini
2021-10-24 15:46                     ` Wolfgang Denk
2021-10-24 16:44                       ` Tom Rini
2021-10-25  7:48                         ` Wolfgang Denk
2021-10-22  8:06               ` Wolfgang Denk
2021-10-22 14:04                 ` Marek Behún
2021-10-22 14:50                 ` Tom Rini [this message]
2021-10-19 22:44 ` [PATCH v9 4/7] sandbox: Use a text-based environment Simon Glass
2021-10-20  6:58   ` Alexander Dahl
2021-10-19 22:44 ` [PATCH v9 5/7] doc: Mention CONFIG_DEFAULT_ENV_FILE Simon Glass
2021-10-19 22:44 ` [PATCH v9 6/7] doc: Improve environment documentation Simon Glass
2021-10-19 22:44 ` [PATCH v9 7/7] bootm: Tidy up use of autostart env var Simon Glass
2021-10-21 14:02 ` [PATCH v9 0/7] env: Allow environment in text files Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211022145012.GH3577824@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=joe.hershberger@ni.com \
    --cc=marek.behun@nic.cz \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=wd@denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.