Traduisez - Übersetzen - Traduzca - Traduza - Tradurre - Translate

Re: Diagnosing "helper app spawn" errors with Netscape 4

Ted Powell (ted@eslvcr.fireplug.net)
Tue, 24 Mar 1998 09:50:16 -0800

On Tue, Mar 24, 1998 at 01:41:35AM -0800, jhenders@bogon.com wrote:
> [...]
> Just curious, but what new features have you found yourself actually
> using? I have 1.14.7 on one box and 2.00.0 on another [...]
> Nothing in the changes file lept out at me as something I'd been dieing
> to see in bash. ;)

Well, having the arithmetic command ((...)) -- not to be confused with
arithmetic expansion $((...)) -- means that you can reduce your use
of expr considerably, without losing compatibility with ksh. (In the
short term, of course, you would lose compatibility with many Linux
installations.)

Instead of the rather ugly

a=`expr $a + 1`

you can do

((a+=1))

Actually, you can accomplish something close with the older bash,
although it's not quite so tidy:

: $((a+=1))

The difference between the arithmetic command and arithmetic expansion
(for those readers who aren't already familiar with it) is that the
arithmetic command is indeed a command, which can stand by itself, whereas
arithmetic expansion is an action taken by the shell, which replaces the
part of the current command line occupied by the $((...)) construct with
the result of evaluating the expression inside. For example:

bash-2.00$ a=2
bash-2.00$ b=3
bash-2.00$ echo xxx$(( a + b ))yyy
xxx5yyy
bash-2.00$

Note that shell variables inside either ((...)) or $((...)) don't need a
dollar sign.

-- 
ted@psg.com  http://psg.com/~ted/  (Ted Powell)
Promote Responsible Net Commerce: Fight Spam! http://spam.abuse.net/