[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: is it really required that arr['1']=bla gives syntax error instead o
From: |
Lawrence Velázquez |
Subject: |
Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1 |
Date: |
Mon, 19 Jul 2021 15:33:16 -0400 |
User-agent: |
Cyrus-JMAP/3.5.0-alpha0-533-gf73e617b8a-fm-20210712.002-gf73e617b |
On Mon, Jul 19, 2021, at 2:00 PM, Greg Wooledge wrote:
> unicorn:~$ ksh
> $ echo $(('1' + 2))
> 51
>
> [...]
>
> Ksh officially wins "most surprising result" for that 51. I guess I
> can see how they got it, but I certainly did not *expect* it. Nor do I
> care to guess whether it satisfies the POSIX wording.
I think it does, insofar as the single quotes are retained (as they
would be within double quotes), and the expression resolves to
"'1' + 2". The surprise is that ksh arithmetic itself is extended
with this "casting" behavior. It works with `let` as well:
$ expr="x = '#' + '%'"
$ let "$expr"
$ typeset -p x
x=72
--
vq
- is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Alex fxmbsw7 Ratchev, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Jesse Hathaway, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Greg Wooledge, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Alex fxmbsw7 Ratchev, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Greg Wooledge, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Alex fxmbsw7 Ratchev, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Lawrence Velázquez, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Greg Wooledge, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Jesse Hathaway, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1, Lawrence Velázquez, 2021/07/19
- Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1,
Lawrence Velázquez <=