bug-bash
[Top][All Lists]
Advanced

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

Problem with array initialization in typeset.


From: Steven W. Orr
Subject: Problem with array initialization in typeset.
Date: Fri, 27 May 2005 13:19:39 -0400

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib  -D_FILE_OFFSET_BITS=64 -O2 -g 
-pipe -m32 -march=i386 -mtune=pentium4
uname output: Linux saturn 2.6.10-1.770_FC3smp #1 SMP Thu Feb 24 14:20:06 EST 
2005 i686 athlon i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 3.0
Patch Level: 14
Release Status: release

Description:
        Array initialization seems to be broken from typeset

Repeat-By:
        typeset -a arr=( 'Hello goodbye' 'peaches pears' )
echo ${arr[0]}
Hello

513 > echo ${arr[0]}
Hello
514 > echo ${arr[1]}
goodbye
*515 > echo ${arr[2]}
peaches
*516 > echo ${arr[3]}
pears
517 > 

The same thing but different can be seen by instead saying
        typeset -a arr=( [0]='Hello goodbye' [1]='peaches pears' )
*518 > echo ${arr[0]}
Hello
519 > echo ${arr[1]}
peaches
520 > echo ${arr[2]}
pears
521 > 

The workaround is to not use initialization in typeset.
typeset -a arr
arr=( 'Hello goodbye' 'peaches pears' )


Fix:




reply via email to

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