[MPlayer-dev-eng] [PATCH] clean up tests in configure

Zoltan Hidvegi mplayer at hzoli.2y.net
Thu Jun 30 18:50:18 CEST 2005


Oded Shimon wrote:
> On Thu, Jun 30, 2005 at 02:45:44PM +0300, Ivan Kalvachev wrote:
> > On 6/30/05, Diego Biurrun <diego at biurrun.de> wrote:
> > > On Fri, Jun 10, 2005 at 12:28:22AM -0700, Corey Hickey wrote:
> > > > I recently came upon this:
> > > >
> > > > [ "$cc_vendor" = "gnu" ] && ([ "$_cc_major" -gt 3 ] || ( [ "$_cc_major"
> > > > = 3 ] && [ "$_cc_minor" -ge 4 ]))
> > > >
> > > > ...over which I prefer:
> > > >
> > > > test "$cc_vendor" = "gnu" && test "$_cc_major" -gt 3 -o "$_cc_major" -eq
> > > > 3 -a "$_cc_minor" -ge 4

Note that instead of ( ... ) you can use { ...; } which does not fork,
but otherwise works very similarly.  Using { ...; }, &&, || is
considered more portable than using test -o and -a.  In fact if I
remember correctly, POSIX does not include -a and -o for test, but
most if not all implementations support it.

> > How about using [[ ]] and (( )). AFAI can read `man bash` they do not

[ ... ]] and (( ... )) was not supported in older versions of bash,
and also I do not think it is part of the POSIX shell standard.

> > Probably `test` should be less used as it invokes external command (on
> > another side, i still wonder why I have /usr/bin/[  ;)
> 
> 19:07) ods15 at linux15:~ $ which test
> test: shell built-in command
> 19:08) ods15 at linux15:~ $ which [
> [: shell built-in command
> 19:07) ods15 at linux15:~ $ bash
> ods15 at linux15:~$ which test
> /usr/bin/test
> ods15 at linux15:~$ which [
> /usr/bin/[
> 
> Damn. bash sucks. zsh is better. :P

I certainly agree that zsh is better, altough I am biased judge,
however this is a user error.  which is builtin in zsh (really coming
from csh), bash does not have it.  If you used type instead, you would
have discovered that `test' is indeed a shell builtin, and it is a
builtin in all the shells I know of, [ and test are just two names for
the same shell builtin.

Zoli




More information about the MPlayer-dev-eng mailing list