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

Re: Shell scripting in Bash



Note that the precedence rules on "-o" and "-a" are messed up, in some of 
the older bourne-based shells (and my bourne scripts, for one, are nearly 
always targeted at ash/sh/ksh/bash/anything_vaguely_posix).  If you don't 
want easy portability (read: a widely available interpreter), use something 
cleaner - like python (Object Oriented scripting from the ground up :).

For wide portability, it doesn't hurt to get into the habit of just 
always using:

if [ a != b ] || [ c != d ]
then
	fee
fi

It doesn't matter in this case, but it does matter for some things 
you might naturally generalize from it, like:

if [ a != b ] && [ b != c ] || [ d != e ] && [ f != g ]
then
	fee
fi

> On Fri, 26 Apr 1996, Dale Scheetz wrote:
> 
> > if [ a != b || c != d ]
> 
> || is a list operator as in
> 	foo || bar
> foo is executed.  bar is executed iff foo returns nonzero.
> 
> You want
> 	if [ a != b -o c != d ]
> above.
> 
> I find the online help much more useful than the manpage.
> 
> Guy
> 


Reply to: