public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] U-boot env variables parsing
Date: Thu, 08 Apr 2010 12:00:05 +0200	[thread overview]
Message-ID: <m2iq82s1qy.fsf@ohwell.denx.de> (raw)
In-Reply-To: <OFEA92751A.43DF6D24-ONC12576F8.006D365D-C12576F8.006EAF8F@transmode.se> (Joakim Tjernlund's message of "Thu, 1 Apr 2010 22:08:59 +0200")

Hi Jocke,

>> > > 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.
>
> what bad do you think it might do? You mentioned the possibility
> to pass arg=$(name) literally(why would you do that?)
> Have you ever done that?

Nope, I haven't, but if some linux commandline parameter needs such a
construct, I surely do not want to change the U-Boot shell to be able to
do it.  The change you propose would make such a thing impossible.

> Then one should be able to
> pass $(linuxip) too, which you can't.

Why do you think so?

=> run nfsargs addip addtty addfb
=> prin ipaddr
ipaddr=192.168.160.43
=> setenv bootargs ${bootargs} \${ipaddr}
=> bootm ${kernel_addr}

[....]

-bash-3.2# cat /proc/cmdline
root=/dev/nfs rw nfsroot=192.168.1.1:/opt/eldk/ppc_6xx
ip=192.168.160.43:192.168.1.1:192.168.83.201:255.255.0.0:pdm360ng:eth0:off panic=1 console=tty0 console=ttyPSC5,115200 fbcon=map:5 video=fslfb:800x480-32 at 60 ${ipaddr}

>> 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.
>
> While you can do that, it is ugly and clumsy(which was why I wrote the patch)
>
> I want the shell to make things simpler/easier for me and the above
> isn't either.

This is a personal preference.  Personally I value the quoted principle
of least surprise more.  Moreover I much rather make all use cases
possible and maybe use some extra characters for exotic ones rather than
precluding a specific use case completely in order to save a few
characters.

Cheers
  Detlev

-- 
SWYM XYZ (Sympathize with your machinery).  [..] In fact it is often
called a no-op, because it performs no operation.  It does, however,
keep the machine running smoothly, just as real-world swimming helps
to keep programmers healthy.             -- Donald Knuth, Fascicle 1
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de

  reply	other threads:[~2010-04-08 10:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01  5:27 [U-Boot] U-boot env variables parsing Nitin Mahajan
2010-04-01 12:15 ` Detlev Zundel
2010-04-01 12:31   ` Joakim Tjernlund
2010-04-01 12:47     ` Wolfgang Denk
2010-04-01 12:56       ` Joakim Tjernlund
2010-04-01 13:05         ` Wolfgang Denk
2010-04-01 13:11           ` Joakim Tjernlund
2010-04-01 14:56             ` Detlev Zundel
2010-04-01 17:13               ` Joakim Tjernlund
2010-04-01 18:27                 ` Wolfgang Denk
2010-04-01 20:08                   ` Joakim Tjernlund
2010-04-08 10:00                     ` Detlev Zundel [this message]
2010-04-08 15:41                       ` Joakim Tjernlund
2010-04-08 16:06                         ` Detlev Zundel
2010-04-08 17:49                           ` Joakim Tjernlund

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=m2iq82s1qy.fsf@ohwell.denx.de \
    --to=dzu@denx.de \
    --cc=u-boot@lists.denx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox