[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare a="$b" if $a previously set as array
From: |
Chet Ramey |
Subject: |
Re: declare a="$b" if $a previously set as array |
Date: |
Sun, 14 Dec 2014 14:45:06 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
On 12/7/14 11:16 PM, Eduardo A. Bustamante López wrote:
> On Sun, Dec 07, 2014 at 07:34:53PM -0800, Linda Walsh wrote:
>> Only if you properly quote "external input".
> Well, that's the whole point, as a script writer, I don't expect to get
> arbitrary code execution here:
>
> | address@hidden:~/t$ unset var; value='[$(ls -l)]=1 [2]=2'; declare -a
> var="($value)"; declare -p var
> | bash: total 0: syntax error in expression (error token is "0")
Yeah, that's what we're discussing.
> Or here:
> | address@hidden:~/t$ a=(1 2 3); k='a[$(ls -l)]'; echo "${a[k]}"
> | bash: total 0: syntax error in expression (error token is "0")
>
> And I *shouldn't* have to worry about that.
But the ship has sailed on this one. Every shell that implements indexed
arrays does what bash does here.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/
- declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/06
- Re: declare a="$b" if $a previously set as array, Chet Ramey, 2014/12/06
- Re: declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/08
- Re: declare a="$b" if $a previously set as array, Linda Walsh, 2014/12/08
- Re: declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/08
- Re: declare a="$b" if $a previously set as array, Eduardo A . Bustamante López, 2014/12/08
- Re: declare a="$b" if $a previously set as array, Linda Walsh, 2014/12/08
- Re: declare a="$b" if $a previously set as array, konsolebox, 2014/12/09
- Re: declare a="$b" if $a previously set as array, Chet Ramey, 2014/12/14
- Re: declare a="$b" if $a previously set as array, konsolebox, 2014/12/15
- Re: declare a="$b" if $a previously set as array, konsolebox, 2014/12/17