[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SLUG] bash



Minh Van <mle@nospam.mail.usyd.edu.au> wrote:
> 1. if [ -n $dirname ] && [ \( -d $dirname \) -a \( -x $dirname \) ];
> then

> 2. if [ -n $dirname ] && [ -d $dirname ] && [ -x $dirname ]; then

Use the second form whenever you can.  && is guaranteed to short circuit while
-a never does.  Also, to use -a safely you have to put in those ugly
brackets :)

And if you shell doesn't have test built-in, well, dump it :)
-- 
Debian GNU/Linux 2.1 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@nospam.gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to slug-request@nospam.slug.org.au with
unsubscribe in the text