public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] Hush 'elif' operation?
@ 2004-01-29 21:04 Robin Gilks
  2004-02-09 21:52 ` Wolfgang Denk
  2004-04-12 14:45 ` Wolfgang Denk
  0 siblings, 2 replies; 3+ messages in thread
From: Robin Gilks @ 2004-01-29 21:04 UTC (permalink / raw)
  To: u-boot

Greetings

I'm trying to get as close to a switch statement in hush shell language 
as possible and thought that a set of if/then/elif/else would be tidier 
than nested if/then/else. It doesn't work how I expected however. The 
example below illustrates the problem - I was expecting execution after 
a true test (in the first 'if' in this case) to continue after the 'fi' 
but instead it ploughs through all the other executable (echo) 
statements having skipped the elif statements. It does correctly skip 
the else clause however :-))

Could someone assist in the navigation of this module to point out where 
would be a good place to start (i.e. some basic principles and 
assumptions of how the parser works).

[apologies for the word wrapping]

=>if iml; then echo "one"; elif iml; then echo "two"; elif iml; then 
echo "three"; else echo "four"; fi
Image at 40340000:
    Image Name:   Linux-2.4.22-20040129-12:57
    Image Type:   PowerPC Linux Kernel Image (gzip compressed)
    Data Size:    630253 Bytes = 615.5 kB
    Load Address: 00000000
    Entry Point:  00000000

one
two
three
=>


Many thanks

-- 
Robin Gilks
Senior Design Engineer          Phone: (+64)(3) 357 1569
Tait Electronics                Fax  :  (+64)(3) 359 4632
PO Box 1645 Christchurch        Email : robin.gilks at tait.co.nz
New Zealand

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot-Users] Hush 'elif' operation?
  2004-01-29 21:04 [U-Boot-Users] Hush 'elif' operation? Robin Gilks
@ 2004-02-09 21:52 ` Wolfgang Denk
  2004-04-12 14:45 ` Wolfgang Denk
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Denk @ 2004-02-09 21:52 UTC (permalink / raw)
  To: u-boot

Dear Robin,

in message <40197548.6060001@tait.co.nz> you wrote:
> 
> I'm trying to get as close to a switch statement in hush shell language 
> as possible and thought that a set of if/then/elif/else would be tidier 
> than nested if/then/else. It doesn't work how I expected however. The 
> example below illustrates the problem - I was expecting execution after 
> a true test (in the first 'if' in this case) to continue after the 'fi' 
> but instead it ploughs through all the other executable (echo) 
> statements having skipped the elif statements. It does correctly skip 
> the else clause however :-))

I confirm that this is a bug of HUSH.

The same problem is present in the HUSH  shell  of  the  most  recent
version of BusyBox, too (v1.00-pre7).

> Could someone assist in the navigation of this module to point out where 
> would be a good place to start (i.e. some basic principles and 
> assumptions of how the parser works).

Well, please feel free to dig into the innards  of  HUSH  (using  the
BusyBox implementation is probably much easier to debug).

We will look into this, too - as time permits.

Best regards,

Wolfgang Denk

-- 
See us @ Embedded World, Nuremberg, Feb 17 - 19,  Hall 12.0 Booth 440
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
"One planet is all you get."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot-Users] Hush 'elif' operation?
  2004-01-29 21:04 [U-Boot-Users] Hush 'elif' operation? Robin Gilks
  2004-02-09 21:52 ` Wolfgang Denk
@ 2004-04-12 14:45 ` Wolfgang Denk
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Denk @ 2004-04-12 14:45 UTC (permalink / raw)
  To: u-boot

Dear Robin,

in message <40197548.6060001@tait.co.nz> you wrote:
> 
> I'm trying to get as close to a switch statement in hush shell language 
> as possible and thought that a set of if/then/elif/else would be tidier 
> than nested if/then/else. It doesn't work how I expected however. The 
...
> =>if iml; then echo "one"; elif iml; then echo "two"; elif iml; then 
> echo "three"; else echo "four"; fi
> Image at 40340000:
>     Image Name:   Linux-2.4.22-20040129-12:57
>     Image Type:   PowerPC Linux Kernel Image (gzip compressed)
>     Data Size:    630253 Bytes = 615.5 kB
>     Load Address: 00000000
>     Entry Point:  00000000
> 
> one
> two
> three
> =>

I just checked in a patch that fixes this problem. Sorry this took so
long.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Command, n.:
            Statement presented by a human and accepted by a computer
in such a manner as to make the human feel as if he is in control.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-04-12 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-29 21:04 [U-Boot-Users] Hush 'elif' operation? Robin Gilks
2004-02-09 21:52 ` Wolfgang Denk
2004-04-12 14:45 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox