[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare a="$b" if $a previously set as array
From: |
Eduardo A . Bustamante López |
Subject: |
Re: declare a="$b" if $a previously set as array |
Date: |
Sun, 7 Dec 2014 22:16:39 -0600 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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:
| dualbus@hp:~/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")
Or here:
| dualbus@hp:~/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.
I know that I can do many things to avoid that, but, why? It's tedious, and
error prone. It shouldn't be this painful to write scripts that take arbitrary
user input. We have enough with word-splitting and quote-all-the-things, to
also be worrying about that.
- 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