bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code Execution in Mathematical Context


From: Greg Wooledge
Subject: Re: Code Execution in Mathematical Context
Date: Thu, 6 Jun 2019 08:53:41 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Thu, Jun 06, 2019 at 11:33:56AM +1000, David wrote:
> Regarding $((...)) when Chet refers above to "the expression between the 
> parens"
> he means whatever is between the parentheses, in this case the three dots.
> 
> If I understand correctly, Chet is saying there that $((...)) is
> parsed as if it was written
> $(("...")) and therefore any single quotes inside the parentheses are
> not special.

But...

On Tue, Jun 04, 2019 at 09:24:27AM -0400, Greg Wooledge wrote:
> wooledg:~$ a=(foo bar baz)
> wooledg:~$ i='$(date >&2)'
> wooledg:~$ echo $(( a[$i] ))
> Tue 04 Jun 2019 09:23:28 AM EDT
> 0

> wooledg:~$ echo $(( 'a[$i]' ))
> bash: 'a[$(date >&2)]' : syntax error: operand expected (error token is 
> "'a[$(date >&2)]' ")

I definitely got different results when I added single quotes.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]