Skip to content

Commit af1c009

Browse files
author
Peter Stephenson
committed
46079: Ignore double quotes in math expressions.
Treat as white space. This is required for compatibility and previously had no use in zsh as it generated an error.
1 parent ae0129b commit af1c009

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2020-06-22 Peter Stephenson <p.stephenson@samsung.com>
2+
3+
* 46079: Src/math.c, Test/C01arith.ztst: Ignore double quotes in
4+
math expression: treat as white space.
5+
16
2020-06-22 Manuel Jacob <me@manueljacob.de>
27

38
* 46091: Doc/Zsh/contrib.yo,

Src/math.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ zzlex(void)
831831
case ' ': /* Fall through! */
832832
case '\t':
833833
case '\n':
834+
case '"': /* POSIX says ignore these */
835+
case Dnull:
834836
break;
835837
default:
836838
if (idigit(*--ptr) || *ptr == '.')

Test/C01arith.ztst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,10 @@
180180
1:bases beyond 36 don't work
181181
?(eval):1: invalid base (must be 2 to 36 inclusive): 37
182182

183+
fail=39
183184
print $(( 3 + "fail" ))
184-
1:parse failure in arithmetic
185-
?(eval):1: bad math expression: operand expected at `"fail" '
185+
0:Double quotes are not treated specially in arithmetic
186+
>42
186187

187188
alias 3=echo
188189
print $(( 3 + "OK"); echo "Worked")
@@ -487,3 +488,8 @@
487488
let noexist==0 )
488489
1:Arithmetic, NO_UNSET part 3
489490
?(eval):2: noexist: parameter not set
491+
492+
print $(( "6+2" / "1+3" ))
493+
0:Double quotes are not treated specially in arithmetic (POSIX)
494+
# and do not do grouping! this is 6 + (2/1) + 3
495+
>11

0 commit comments

Comments
 (0)