[U-Boot] [PATCH] cmd_nvedit.c: Add env exists command

Andrew Ruder
2013-10-23T14:30:58Z

On Wed, Oct 23, 2013 at 06:55:02AM -0700, James Chargin wrote:
> I have, more recently, been using scripting of the form
>
> if test "X" != "X${var}"; then
> echo defined
> else
> echo undefined
> fi

Thanks for the feedback.

I was attempting to do something like that originally but was hitting
problems related to the expansion which I'm still tracking down:

WRONG:
$ set var
$ test "x${var}" = "x" && echo undefined
undefined
$ set var 1
$ test "x${var}" = "x" && echo undefined
$ set var "1; 2; 3"
$ test "x${var}" = "x" && echo undefined
>> undefined

It DOES seem to work a lot better with != as you mentioned above
though...

RIGHT:
$ set var
$ test "x${var}" != "x" && echo defined
$ set var 1
$ test "x${var}" != "x" && echo defined
defined
$ set var "1; 2; 3"
$ test "x${var}" != "x" && echo defined
defined

- Andy