choice of control operators in scripts
Denys Vlasenko
vda.linux at googlemail.com
Tue May 13 13:12:38 UTC 2008
On Tuesday 13 May 2008 14:28, Cristian Ionescu-Idbohrn wrote:
> On Tue, 13 May 2008, Bernhard Fischer wrote:
>
> > And of course i've seen those dreaded test(1) impls that
> > misinterpret arbitrary strings as args (hence "x$myvariable" != "x")
> > and some ancient test(1) impls don't support -n and/or -z, fwiw.
>
> Alright. I think it's ok using the x-thing in tests. I have
> no problems with using that. Question is what makes this:
I am not insisting on x thing. I personally prefer it, but
will not require it to be used.
> [ "x$myvariable" != "x" ]
>
> or this:
>
> [ x"$foo" != x"" ]
I think this one is the most readable. x is visually separated from
the strings, making it clearer that it is (logically) not part of them.
> or this:
>
> [ x"$foo" != x"bar" ]
This one is the same as above (just with different string).
--
vda
More information about the busybox
mailing list