From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7092 invoked by alias); 22 Dec 2009 22:08:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27538 Received: (qmail 13644 invoked from network); 22 Dec 2009 22:08:06 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VERIFIED autolearn=ham version=3.2.5 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.221.191 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=doPnPiFOP9O/HG087YvGYxXqNU43LueFrgT0P9QUVOE=; b=xGLbKTtHy7CNb2FMH7Ygr6S1Gtwo21SfGe/KxEkybCzAitvCEQvhDGmddxrTl1adIZ EbI6CcjO9v99JRl+RBBF0wtJSUkifF4PBaU51xqZ42V+qVqIx/Rdc+sA5C7HSNaFFphT ieOxJiy+khwrfQYbj5KtYV/7ecx/lYcMNLt7s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=gAqV6jCcWbI2Fpi/KoMJNbVF5S0HELRhLCm2qeBRsOgF9dEDFb8Eyk7Qt1gXOZWhcb PYRxZJiGFP1wmJtQU29HvG7AwrnDKpG+FzBParmfRTbUhD+snC2RPkABLFgSJ6mc0EGW +V/OJO2GC/cvsAGG+EycSjuEAs1ndymUbqlfY= MIME-Version: 1.0 Sender: barton.schaefer@gmail.com In-Reply-To: <20091222113413.GA9234@squonk.masqnet> References: <20091219211403.GA94709@stack.nl> <20091221101508.GA1634@squonk.masqnet> <4B2FB116.4070900@case.edu> <20091221175312.GA16707@squonk.masqnet> <20091222113413.GA9234@squonk.masqnet> Date: Tue, 22 Dec 2009 14:02:28 -0800 X-Google-Sender-Auth: f3fbe5e048eb7d00 Message-ID: <6bb609560912221402i6bfd07b8ob3f1cb2d9af2a1cc@mail.gmail.com> Subject: Fwd: command substitutions starting with $(( From: Bart Schaefer To: zsh-workers@zsh.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Tail of a fairly interesting thread on the austin-group (POSIX) list. ---------- Forwarded message ---------- From: Geoff Clare Date: Tue, Dec 22, 2009 at 3:34 AM Subject: Re: command substitutions starting with $(( To: austin-group-l@opengroup.org Philip Guenther wrote, on 21 Dec 2009: > > On Mon, Dec 21, 2009 at 9:53 AM, Geoff Clare wrote: > ... > > Are you claiming there are text sequences such that $((text)) is > > syntactically valid both as an arithmetic substitution and as a > > command substitution, and it is not a "single subshell" command > > substitution? > > > > Unless such text sequences exist, it seems clear that the shell is > > required to distinguish between the two cases based on which one the > > syntax is valid for. > > How about: > > cat=3D1 ; EOH=3D3; echo $(( cat < + ( ( > EOH > ) && ( cat < ) ) + 1 + > EOH > )) We have a winner. =A0I'm impressed :-) This means we do need to make a change to the standard. =A0The tricky part is going to be deciding exactly what to change. Since it's a simple matter for application writers to use "$( (" instead of "$((" when they are writing a command substitution that starts with a subshell, I think it would be appropriate for the standard to say that arithmetic expansion has precedence. I.e. if $(( introduces a syntactically valid arithmetic expansion, then an arithmetic expansion will be performed. =A0Otherwise if $(( introduces a syntactically valid command substitution, then a command substitution will be performed. =A0If the syntax is valid for neither, then it is unspecified what kind of syntax error the shell reports. =A0(Or a modification of this which retains the "single subshell" rule.) This appears to match what current shells do. =A0All the shells I tried Philip's example in output 256. -- Geoff Clare The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England