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]