Array declaration doesn't seem to work properly in Ver 3.2
From: [EMAIL PROTECTED] To: bug-bash@gnu.org,[EMAIL PROTECTED] Subject: Array declaration doesn't seem to work properly in Ver 3.2 Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall uname output: Linux Demos 2.6.22-15-generic #1 SMP Tue Oct 21 23:47:12 GMT 2008 i686 GNU/Linux Machine Type: i486-pc-linux-gnu Bash Version: 3.2 Patch Level: 25 Release Status: release Description: Declare: not found error read: -a illegal option I have two machines running Bash ver. 3.2 and one running 3.1. I get the above errors always on the 3.2 boxes but not the 3.1 box. statements that cause the problem are: declare -a arrayname read -a arrayname Repeat-By: here is a test script that repeats the errors: #!/bin/bash declare -a colors # Permits declaring an array without specifying size. echo "Enter your favorite colors (separated from each other by a space)." read -a colors # Special option to 'read' command, # allowing it to assign elements in an array. echo [EMAIL PROTECTED] # Special syntax to extract number of elements in array. # element_count=${#colors[*]} works also. index=0 # List all the elements in the array. while [ $index -lt $element_count ] do echo ${colors[$index]} let "index = $index + 1" done # Each array element listed on a separate line. # If this is not desired, use echo -n "${colors[$index]} " echo # Again, list all the elements in the array, but using a more elegant method. echo [EMAIL PROTECTED] # echo ${colors[*]} works also. echo exit 0 _ Fix: I sure wish I knew!! if you can help me figure out why this works on one machine but not the two with newer versions could you please let me know. Thanks, Jim Adamson [EMAIL PROTECTED]
Bash crashes on tab completion after unset COMP_WORDBREAKS
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: x86_64-pc-linux-gnu-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O2 -march=native -pipe -fstack-protector uname output: Linux aes 2.6.26-DJC-AES #1 SMP Thu Jul 17 22:09:37 PDT 2008 x86_64 Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 3.2 Patch Level: 33 Release Status: release Description: It seems like once COMP_WORDBREAKS is unset, the actually completion mechanism of bash gets very unhappy. Presumably maybe it shouldn't work very well after this is unset, but it's probably best if it doesn't crash outright. Sorry, I'm not sure if this has been fixed in trunk, but given that it's existing across several patch levels, I figured it might still be live. Blogged with an image on: http://djcapelis.livejournal.com/111233.html Reproduced by a friend using 3.2.17(1)-release (The regular bash build on OS X.) Reproduced again using 3.2.39(1)-release (i686-pc-linux-gnu) Reproduced again using 3.1.17(1)-release (i686-redhat-linux-gnu) BUT GOT DIFFERENT OUTCOME: bash spins instead of crashing CANNOT REPRODUCE on 3.00.15(1)-release (i686-redhat-linux-gnu) CANNOT REPRODUCE on 3.00.16(1)-release (sparc-sun-solaris2.10) Reproduce by: 1) unset COMP_WORDBREAKS 2) type ba, press tab 3) Bash should crash Repeat-By: 1) unset COMP_WORDBREAKS 2) type ba, press tab 3) Bash should crash
Re: Array declaration doesn't seem to work properly in Ver 3.2
On Mon, Nov 10, 2008 at 9:10 PM, Jim Adamson <[EMAIL PROTECTED]> wrote: > From: [EMAIL PROTECTED] > To: bug-bash@gnu.org,[EMAIL PROTECTED] > Subject: Array declaration doesn't seem to work properly in Ver 3.2 > > Description: >Declare: not found error >read: -a illegal option Are you running your script using "sh script" ?