bug-bash
[Top][All Lists]
Advanced

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

Re: Intriguing error with arithmetic evaluation


From: Stephane Chazelas
Subject: Re: Intriguing error with arithmetic evaluation
Date: Tue, 23 Aug 2016 17:15:25 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2016-08-12 14:22:32 -0400, Chet Ramey:
[...]
> The relevant change was probably the change in the set of commands to which
> `set -e' applies.  The (( command (among others) was added to that list
> in bash-4.1.  The change was the result of Posix changing the semantics
> of the errexit option and expanding its scope from simple commands to
> all commands.
> 
> The (( command returns 1 if the expression evaluates to 0.  When `level' is
> 0, level++ returns a 0 value, and (( returns a status of 1.
[...]

POSIX doesn't specify ((...)) (explicitely leaves it
unspecified), so is out of POSIX scope anyway.

It was introduced by ksh88.

There and in ksh93 (but not pdksh nor zsh)

ksh -c '((0)); echo X'

outputs X

For:

ksh -ec '[[ -z . ]]; echo X'

I see a difference between ksh88 (Solaris /usr/bin/ksh) which
displays the X (like bash<4.1) and ksh93 (u+) which doesn't any more.

In any case, I'd go with Greg's advice to avoid "set -e".

-- 
Stephane



reply via email to

[Prev in Thread] Current Thread [Next in Thread]