[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [3.0.13] declare -a a=('$0') + bug with exported array
From: |
Stephane CHAZELAS |
Subject: |
Re: [3.0.13] declare -a a=('$0') + bug with exported array |
Date: |
Thu, 16 Sep 2004 14:54:57 +0100 |
User-agent: |
Mutt/1.5.6i |
On Wed, Sep 15, 2004 at 04:46:04PM -0400, Chet Ramey wrote:
[...]
> True enough, though some versions of ksh try (though not using this format).
> caleb.INS.CWRU.Edu(2)$ cat x15
> zzz=(1 2)
>
> export zzz
> printenv zzz
> caleb.INS.CWRU.Edu(2)$ ksh93 ./x15
> 1
[...]
That sounds quite normal to me, given what arrays are in ksh.
var=foo
is supposed to be a shortcut for
var[0]=foo
In zsh, it's different as there are two different variable types
for scalar and arrays.
I thought bash behaved the same way as ksh, it doesn't seem to
be the case.
There actually seems to be a bug in bash:
bash-3.00$ a=foo
bash-3.00$ export a
bash-3.00$ env | grep a=
a=foo
bash-3.00$ a[1]=bar
bash-3.00$ echo "$a"
foo
bash-3.00$ env | grep a=
a=foo
bash-3.00$ b[0]=FOO
bash-3.00$ export b
bash-3.00$ env | grep a=
bash-3.00$ env | grep b=
bash-3.00$ echo $a
foo
bash-3.00$ echo $b
FOO
Note the second call to "env" that reports "a=foo", while the
third one doesn't, and nothing was done WRT the a variable in
between!
bash-3.00$ echo ${BASH_VERSINFO[*]}
3 00 13 1 release sparc-sun-solaris2.8
regards,
Stephane
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________