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

[SLUG] Re: bash



On Wed, Jun 21, 2000 at 11:35:19PM +0000, Herbert Xu wrote:
| 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.

Well, it's only worth it for expensive tests or tests when some depend
on success of others.

| Also, to use -a safely you have to put in those ugly
| brackets :)

Not so. They're only needed if you have precedence issues, which don't
obtains in the examples cited.
-- 
Cameron Simpson, DoD#743        cs@nospam.zip.com.au    http://www.zip.com.au/~cs/

Every normal man must be tempted at times to spit on his hands, hoist the
black flag, and begin slitting throats.	- H.L. Mencken
--
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