|
| From: | Dave B |
| Subject: | Re: Bug in array populating does not respect quotes |
| Date: | Thu, 24 Sep 2009 17:37:21 +0100 |
| User-agent: | KMail/1.11.2 (Linux/2.6.28-15-generic; KDE/4.2.2; x86_64; ; ) |
On Thursday 24 September 2009 16:38:12 David Martin wrote:
> Description:
> When populating an array from a string in a variable does not
> handle quotes.
>
> Repeat-By:
>
> ~$ declare -a samplearray
> ~$ samplearray=( x y 'z k')
> ~$ echo ${samplearray[2]}
> z k
> ~$ samplestring="x y 'z k'"
> ~$ samplearray=( $samplestring )
> ~$ echo ${samplearray[2]}
> 'z
Not a bug. This is expected behavior. To do what you want, use eval:
~$ samplestring="x y 'z k'"
~$ eval samplearray=( "$samplestring" )
~$ echo "${samplearray[2]}"
z k
--
D.
| [Prev in Thread] | Current Thread | [Next in Thread] |