Fun w/ test :)
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Tue Jul 22 13:10:29 UTC 2008
On Tue, 22 Jul 2008, Denys Vlasenko wrote:
> So, now, do you see why x"str" trick is actually not so silly?
We're now debating:
test EXPRESSION
which differs from:
[ EXPRESSION ]
Still...
> On Thursday 15 May 2008 02:20, Paul Fox wrote:
> > > You're talking again of som general case. In this particular case:
> > >
> > > [ x"$foo" != x ]
The above is silly, but:
test x"$foo" != x
is not that silly, but still silly :), as:
test "$foo"
or:
test -z "$foo"
or:
! test "$foo"
should cover most cases.
> > > it's totally useless quoting an empty string after the 'x' on the
> > > right side of the condition.
> >
> >
> > sigh. why would you write this at all? either say what you
> > mean, and write:
> > [ "$foo" != "" ]
The above is silly too.
> > or say it in the usual shell idiom and write:
> > [ "$foo" ]
Above is ok.
test "$foo"
is ok too.
> > or
> > [ -n "$foo" ]
Above or:
test -n "$foo"
waste 3 bytes to no purpose, so they're silly.
> > but this
> > [ x"$foo" != x ]
> > or this
> > [ x"$foo" != x"" ]
> >
> > are just silly.
Yes, and the 2nd form is sillier then the 1st :)
But, on the other hand, I might be totally wrong about all of it :)
Cheers,
--
Cristian
More information about the busybox
mailing list