[U-Boot] U-boot env variables parsing

Wolfgang Denk wd at denx.de
Thu Apr 1 20:27:47 CEST 2010


Dear Joakim Tjernlund,

In message <OF5552925C.8F998468-ONC12576F8.005E3247-C12576F8.005E9BF2 at transmode.se> you wrote:
>
> > To me it looks like the new code would indeed do a "greedy" substitution
> > only stopping when no more substitutions can be done.  This is very
> > un-unixy and thus not something I'd like to see as a default behaviour.
> 
> Why not? What is gained by the current method?

We follow the principle of least surprise [1]; the command line
interpeter in U-Boot should behave as similar to a (say, POSIX
compatible) shell as possible. Restrictions and deviations are not
intentional, but caused by the attempt to do with a minimal memory
footprint.

Like Detlev I feel/fear that the suggested change will cause more
annoyance due to unexpected behaviour that it will do good.


I also see little actual need for such an extension, as in all cases
I've seen so far it has been possible to acchieve the goal without
code changes by just minimal adjustments of the definitions. For
example, your code:

linuxip=ip=$(ipaddr)::$(gatewayip):$(netmask):$(hostname):$(linuxif):off
tboot=setenv bootargs $(linuxroot) $(linuxip) $(extra);tftp 100000; bootm 100000

could be rewritten from plain variable definitions into an equivalent
command sequence, like that:

setenv setip 'setenv bootargs ${bootargs} ip=${ipaddr}::${gatewayip}:${netmask}:${hostname}:${linuxif}:off'

Do the same for "linuxroot" (=> setroot) and "extra" (=> setextra),
and then use:

setenv tboot 'run setroot setip setextra;tftp 100000;bootm'

will do exactly what you want. Detlev quoted similar code earlier.
This is what many, many existing boards use, and what we explain in
great detail in the manual.


[1] http://en.wikipedia.org/wiki/Principle_of_least_surprise


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
Old programmers never die, they just become managers.


More information about the U-Boot mailing list