[U-Boot] u-boot script "test"

Sridhar Addagada sridhar_a at yahoo.com
Tue Jan 24 12:30:27 CET 2012


For now i got around this problem with a negative test
set x

if test $x != 1 then echo "No"; else echo "Yes"; fi

with this if x is not present i get No, even in the case when x is present and set any other value (not 1)
when i do "set x 1" and run the test again i get "Yes"

Thanks
Sridhar



________________________________
 From: Wolfgang Denk <wd at denx.de>
To: Sridhar Addagada <sridhar_a at yahoo.com> 
Cc: "u-boot at lists.denx.de" <u-boot at lists.denx.de> 
Sent: Tuesday, January 24, 2012 4:13 PM
Subject: Re: [U-Boot] u-boot script "test"
 
Dear Sridhar Addagada,

In message <1327396047.99588.YahooMailNeo at web120201.mail.ne1.yahoo.com> you wrote:
>
> What is the behavior of test command when the variable is not present in the uboot env

It should be the same as in any other bourne compatible shell.

> set x

Note that "set" for "setenv" may or may not work, depending on your
command selection.

> if test $x = 1; then echo "Yes"; else echo "No"; fi

This should provoke an error from the "test" command which misses an
argument.

> in the above case I get Yes echoed back.

That's a bug then.  Patches welcome...

> Is there any way to test the presence of a variable in uboot script?

This should be possible like in any other shell...



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
Alan Turing thought about criteria to settle the question of  whether
machines  can think, a question of which we now know that it is about
as relevant as the question of whether submarines can swim.
                                                   -- Edsger Dijkstra


More information about the U-Boot mailing list