[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: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: is it really required that arr['1']=bla gives syntax error instead of parse '1' as 1 |
Date: |
Mon, 19 Jul 2021 18:27:28 +0200 |
(( "2" + 4 ))
noerr
On Mon, Jul 19, 2021, 17:57 Greg Wooledge <greg@wooledge.org> wrote:
> On Mon, Jul 19, 2021 at 10:30:36AM -0500, Jesse Hathaway wrote:
> > That does seem inconsistent with how bash treats double quoted array
> > subscripts and variable subscripts.
> >
> > all these work:
> >
> > arr["1"]=bar
> > one='1'
> > arr[$one]=foo
> > arr["$one"]=baz
> >
>
> In <https://lists.gnu.org/archive/html/bug-bash/2021-02/msg00189.html>
> Chet says that "The contents of (( are expanded as if they are between
> double quotes". I wonder if this generalizes to *all* arithmetic
> contexts.
>
> unicorn:~$ (( 4 + '1' ))
> bash: ((: 4 + '1' : syntax error: operand expected (error token is "'1' ")
> unicorn:~$ arr['1']=bla
> bash: '1': syntax error: operand expected (error token is "'1'")
> unicorn:~$ echo "${LOGNAME:'1'}"
> bash: LOGNAME: '1': syntax error: operand expected (error token is "'1'")
> unicorn:~$ let x='1'+2
> unicorn:~$ echo "$x"
> 3
> unicorn:~$ [[ 4 -gt '1' ]]
> unicorn:~$
>
> Hmm. Not all of them, apparently. Some of them.
>
>
- 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 <=
- 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, 2021/07/19