[PATCH v10 3/9] env: Allow U-Boot scripts to be placed in a .env file

Wolfgang Denk wd at denx.de
Sun Oct 24 17:41:46 CEST 2021

Dear Tom,

In message <20211022142912.GF3577824 at bill-the-cat> you wrote:
> > However, '\' is also a legal character in a variable name (and
> > doubled backslashes or apostrophes etc. are legal, too), so
> > above line should actually set the environment variable "maximum\+"
> > to "value".
> I feel I should preface this with "I am cranky".  Now I see that I can
> indeed do:
> => setenv foo\\bar baz
> => printenv foo\\bar
> foo\bar=baz
> on a system today.  To what value, I know not.

That's simple: historical reasons.

I already explained that: when I wrote the environment code, memory
was a very precious resource, so I implemented absolutely no
checking that could be avoided.  '=' was nevessary to separate name
from value, and NUL was necessary to terminate an entry. All other
characters where legal.

Yes, this can be misused to have all kinds of fun, like embedded
terminal control sequences or "invisible" variable names:

	=> setenv 'foo^H^H^H' bar
	=> printenv

You don't like it? Don't do it, then.

Yes, robust programming is something different, but at that time we
were fighting for 10 or 20 byte code size - there were so many
systems where U-Boot, Linux, and root file system had to fit into
4 MB flash or so.

Best regards,

Wolfgang Denk

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Any sufficiently advanced bug is indistinguishable from a feature.
                                                      - Rich Kulawiec

More information about the U-Boot mailing list