[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
locally declared arrays do not act as arrays
From: |
Andrew Stitt |
Subject: |
locally declared arrays do not act as arrays |
Date: |
Sun, 21 May 2006 11:26:42 -0700 |
User-agent: |
Mutt/1.4.2.1i |
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O -march=pentium-m -mmmx
-mfpmath=sse -msse2 -pipe -ffast-math -funroll-loops -O3
uname output: Linux courier 2.6.11 #6 Sun May 8 23:59:20 PDT 2005 i686 unknown
unknown GNU/Linux
Machine Type: i686-pc-linux-gnu
Bash Version: 3.0
Patch Level: 16
Release Status: release
Description:
when I declare a local variable as an array it still acts as a scalar,
not as an array.
I discovered that if I seperate the local declaration from the
initialization, the variable properly acts as an array.
Repeat-By:
f() {
local B=("a" "b")
echo $B
C=("a" "b")
echo $C
}
A=("a" "b")
echo $A
f
Produces:
a
(a b)
a
Workaround:
split the declaration and initialization:
local B
B=("a" "b")
- locally declared arrays do not act as arrays,
Andrew Stitt <=