From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24081 invoked by alias); 15 Apr 2015 09:13:47 -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: 34892 Received: (qmail 1015 invoked from network); 15 Apr 2015 09:13:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7f1e6d00000617c-3b-552e28b22401 Date: Wed, 15 Apr 2015 10:03:24 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: broken parsing with $((`:`)) Message-id: <20150415100324.296ffa3e@pwslap01u.europe.root.pri> In-reply-to: <20150415030531.GA8187@vapier> References: <20150415030531.GA8187@vapier> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGLMWRmVeSWpSXmKPExsVy+t/xy7qbNPRCDdad4bM42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGS2Nd1kKJnBWHPs5lb2BcSF7FyMnh4SAicS3xQdYIGwxiQv3 1rN1MXJxCAksZZSYuPYfM4SzhEniy7MOKGcbo8TWd28ZQVpYBFQlVsx4wwpiswkYSkzdNBss LiIgLnF27XmwscICmhLPTj0Ai/MK2Eu8/L6FCcTmFNCW+P9hE1hcSEBLYtHblWBz+AX0Ja7+ /cQEcZK9xMwrZ6B6BSV+TL4HNpMZqH7ztiZWCFteYvOat8wQc9QlbtzdzT6BUWgWkpZZSFpm IWlZwMi8ilE0tTS5oDgpPddIrzgxt7g0L10vOT93EyMkbL/uYFx6zOoQowAHoxIP7w0ZvVAh 1sSy4srcQ4wSHMxKIrwJgkAh3pTEyqrUovz4otKc1OJDjEwcnFINjNfLF4npbW023BZjUKov sjZSf/GbYIZtFQkJn1JmeV1xzT3pwZsYaNHEftg7Qj1Hoe/C+kq+5Vsur2PJ89k5Tz3XYZ7+ qjk/nRMi/08vSjITvKd17dDz535RtiJ/zWa2Z18/zqnhIKLfLv+7Jfi1/1+TPz1KESV7o8Nz innqOmd6s9xabpGvxFKckWioxVxUnAgAJaB+qDkCAAA= On Tue, 14 Apr 2015 23:05:31 -0400 Mike Frysinger wrote: > looks like zsh doesn't correctly parse this: > $ zsh -c 'echo $((`:`))' > zsh:1: bad math expression: illegal character: \M-] > > looks like it's related to the subshell not outputting anything. Yes, indeed --- there's a funny internal special case for empty strings that I never quite get my head around. (Please, God, make the problems with command and math substitution parsing stop now.) pws diff --git a/Src/math.c b/Src/math.c index c047725..f2c72d5 100644 --- a/Src/math.c +++ b/Src/math.c @@ -1398,7 +1398,7 @@ matheval(char *s) if (!mlevel) outputradix = outputunderscore = 0; - if (!*s) { + if (!*s || *s == Nularg) { x.type = MN_INTEGER; x.u.l = 0; return x; diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst index d3176dd..e2dfe56 100644 --- a/Test/C01arith.ztst +++ b/Test/C01arith.ztst @@ -383,4 +383,7 @@ print ${$(( $1 * 100 ))%%.[0-9]#}) 0:Arithmetic substitution nested in parameter substitution >3246 - + + print $((`:`)) +0:Null string in arithmetic evaluation after command substitution +>0