Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: broken parsing with $((`:`))
- X-seq: zsh-workers 34892
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: broken parsing with $((`:`))
- Date: Wed, 15 Apr 2015 10:03:24 +0100
- In-reply-to: <20150415030531.GA8187@vapier>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <20150415030531.GA8187@vapier>
On Tue, 14 Apr 2015 23:05:31 -0400
Mike Frysinger <vapier@xxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author