bug-bash
[Top][All Lists]
Advanced

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

Re: Is bash dying or dead (was Re: 4.1 is "$((( ))) an 'official operato


From: Chet Ramey
Subject: Re: Is bash dying or dead (was Re: 4.1 is "$((( ))) an 'official operator, if $(( )) isn't?
Date: Wed, 10 Aug 2011 22:53:15 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.18) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11

On 8/10/11 8:44 PM, Linda Walsh wrote:

> --------------------
>     It sounded to me like $(( )) would be translated into "$( (xxxx) )",
> turning off arithmetic expansion.  Did I read that incorrectly?

Yes.  You missed the content of the resolution and changed language
in the standard:

"The syntax of the shell command language has an ambiguity for
expansions beginning with "$((", which can introduce an arithmetic
expansion or a command substitution that starts with a subshell.
Arithmetic expansion has precedence; that is, the shell shall
first determine whether it can parse the expansion as an
arithmetic expansion and shall only parse the expansion as a
command substitution if it determines that it cannot parse the
expansion as an arithmetic expansion. "

and

"Arithmetic expansions have precedence over command substitutions.
That is, if the shell can parse an expansion beginning with "$(("
as an arithmetic expansion then it will do so. It will only
parse the expansion as a command substitution (that starts with
a subshell) if it determines that it cannot parse the expansion
as an arithmetic expansion."

> If not, then wouldn't
> $((( ))) be turned into $( (( )) ), meaning the arith returns a status,
> and not the calculation.  (I've tested this, and this is the case.

This is demonstrably false.

$ cat x5
echo $((( 4+3 )))
$ ../bash-4.0-patched/bash ./x5
7
$ ../bash-4.1-patched/bash ./x5
7
$ ../bash-4.2-patched/bash ./x5
7


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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