Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #12295

Re: Command substitution starting with a (()) expression should fail

Path csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!usenet.stanford.edu!not-for-mail
From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Command substitution starting with a (()) expression should fail
Date Sun, 31 Jan 2016 19:51:22 -0500
Organization ITS, Case Western Reserve University
Lines 32
Approved bug-bash@gnu.org
Message-ID <mailman.3286.1454287890.843.bug-bash@gnu.org> (permalink)
References <CA+M2tpFhbTYZkWtfWdN74NyODC5Puee62Va9O0Sj=wGbbRYsVg@mail.gmail.com>
Reply-To chet.ramey@case.edu
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1454287891 30511 208.118.235.17 (1 Feb 2016 00:51:31 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu
To Michael Diamond <diamondm@google.com>, bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.5.0
In-Reply-To <CA+M2tpFhbTYZkWtfWdN74NyODC5Puee62Va9O0Sj=wGbbRYsVg@mail.gmail.com>
X-Mirapoint-Virus-RAPID-Raw score=unknown(0), refid=str=0001.0A020206.56AEAC0B.0043,ss=1,re=0.000,fgs=0, ip=98.17.231.242, so=2015-08-12 04:07:17, dmn=2011-05-27 18:58:46
X-Mirapoint-Loop-Id 8fcda1d1153362fc7aa3a674a778083e
X-Junkmail-Whitelist YES (by domain whitelist at mpv1-2015.case.edu)
X-Mirapoint-Virus-RAPID-Raw score=unknown(0), refid=str=0001.0A020204.56AEAC0B.012C,ss=1,re=0.000,fgs=0, ip=98.17.231.242, so=2015-08-12 04:07:17, dmn=2011-05-27 18:58:46
X-Mirapoint-Loop-Id d1cbd5e4df9df60f04d5dfa94b8bf5c3
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy]
X-Received-From 129.22.103.226
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:12295

Show key headers only | View raw


On 1/31/16 7:26 PM, Michael Diamond wrote:

> Bash Version: 4.3
> Patch Level: 39
> Release Status: release
> 
> Description:
> I'm told $((( $exit_code == 0 )) && echo GREEN || echo RED) should fail
> to parse, because $(( should be the first token, not $(.

The way I read Posix, the bash behavior is allowed:

"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."

One of the criteria bash uses to determine whether it's a valid arithmetic
expression is whether or not the parentheses are balanced.

It's basically up to the application to remove the ambiguity.

Chet

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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Command substitution starting with a (()) expression should fail Chet Ramey <chet.ramey@case.edu> - 2016-01-31 19:51 -0500

csiph-web