
What is the behavior of test command when the variable is not present in the uboot env
set x if test $x = 1; then echo "Yes"; else echo "No"; fi
in the above case I get Yes echoed back.
Is there any way to test the presence of a variable in uboot script?
Thanks Sridhar

Dear Sridhar Addagada,
In message 1327396047.99588.YahooMailNeo@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

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@denx.de To: Sridhar Addagada sridhar_a@yahoo.com Cc: "u-boot@lists.denx.de" u-boot@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@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
participants (2)
-
Sridhar Addagada
-
Wolfgang Denk