Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: arithmetic operator precedence



On 2008-06-19 17:20:36 +0100, Stephane Chazelas wrote:
> I'm under the impression your misunderstand the purpose of
> POSIX. POSIX is a tool to help people write portable
> applications (when it comes to shells, that means _scripts_).
> 
> You cannot write z=$(( x <op> y ))
> 
> in a POSIX script, because the result is unspecified.
> 
> z=$(($x <op> $y))
> 
> is specified (with the conditions I detailed).
> 
> If in your script, you make sure $x and $y are integer constants
> (as in [-+]?(0[xX][a-fA-F0-9]+|0[0-7]+|[1-9][0-9]*)), then it
> will work as expected.

I think it is useless to continue the discussion with someone that
hasn't read what POSIX says.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author