In message <1327404627.60813.yahoomail...@web120202.mail.ne1.yahoo.com>
> 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 I've experienced a similar situation. For now, I'm using U-Boot 2010.12. I want to test existence of environment var without any console output about the result, only control of conditional statement. I've found that the following provides what I need, even though it is a bit hackish. My configuration defines CONFIG_SYS_DEVICE_NULLDEV so I can redirect stdout and hide console output during existence testing. => setenv stderr nulldev => if printenv a; then echo yes; else echo no;fi ## Error: "a" not defined no => coninfo List of available devices: serial 80000003 SIO stdin stdout nulldev 80000003 SIO stderr This seems a bug, the error message goes to stdout, rather than stderr; but you decide how you think error messages should work. To work with this as it is: => setenv t 'setenv stdout nulldev;if printenv a; then setenv stdout serial; echo set; true; else setenv stdout serial;echo not set;false; fi' => => printenv a ## Error: "a" not defined => run t not set => setenv a 1 => run t set => run t && echo 2 set 2 => setenv a => run t && echo 2 not set => Notice that use of printenv does not expand the environment variable so there is never any issue with what that expands to. If the hush shell is present, a hush variable can be used as a "parameter" to the testing script => setenv t 'setenv stdout nulldev;if printenv $var;then setenv stdout serial;true;else setenv stdout serial;false;fi' => => setenv b => if var=b;run t; then echo yes; else echo no; fi no => setenv b 1 => if var=b;run t; then echo yes; else echo no; fi yes => I hope this is helpful. Jim _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot