bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

local array variables problem


From: Joseph Myers
Subject: local array variables problem
Date: Sun, 07 May 2006 22:55:01 +0000

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/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2
uname output: Linux digraph 2.6.16.14 #1 SMP PREEMPT Fri May 5 00:45:34 UTC 
2006 i686 unknown unknown GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 3.1
Patch Level: 17
Release Status: release

Description:

When a local array variable is initialized in the "local" command
using the outer variable of the same name, the list of elements is not
processed correctly.

Repeat-By:

Consider the code:

f() {
    echo "${#a[@]}"
    local -a a=("${a[@]}")
    echo "${#a[@]}"
}

a=("a" "b c" "d")
echo "${#a[@]}"
f

It initializes a local array from the outer array of that name.  It
should display:

3
3
3

However, with bash 3.1 patch 17 it displays:

3
3
0

(and with bash 3.0 patch 16 it displays:

3
3
4

)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]