bug-bash
[Top][All Lists]
Advanced

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

setting array values


From: Jim Thomas
Subject: setting array values
Date: Mon, 3 Dec 2001 16:44:07 -1000 (HST)

Configuration Information [Automatically generated, do not change]:
Machine: hppa1.1
OS: hpux10.20
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='hppa1.1' 
-DCONF_OSTYPE='hpux10.20' -DCONF_MACHTYPE='hppa1.1-hp-hpux10.20' 
-DCONF_VENDOR='hp' -DSHELL -DHAVE_CONFIG_H -DHPUX   -I.  -I. -I./include 
-I./lib -I/usr/local/include -g -O2
uname output: HP-UX atlas B.10.20 A 9000/712 2007201070 two-user license
Machine Type: hppa1.1-hp-hpux10.20

Bash Version: 2.05
Patch Level: 0
Release Status: release

Description:
        I'm having problems getting array variables assigned, albeit in an
obscure way :-)  Since bash's definition of "POSIX conformant" doesn't
match HP's definition, I'm trying to define a function to hide the difference.
So both the array name and the values have to be variables, and I can't get
bash to cooperate.  The minimal problem is shown in two ways in the repeat
by section below.  (For now I'll skip the function, but IMHO the below should
work :-)

Repeat-By:

Script started on Mon Dec  3 16:27:49 2001
$ /usr/local/src/gnu/bash-2.05/bash
bash-2.05$ pwd
/h/thomas
bash-2.05$ /usr/local/src/gnu/bash-2.05/bash --version
GNU bash, version 2.05.0(1)-release (hppa1.1-hp-hpux10.20)
Copyright 2000 Free Software Foundation, Inc.
bash-2.05$ declare -a a=(1 2 3)
bash-2.05$ echo ${a[*]}
1 2 3
bash-2.05$ set 3 4 5
bash-2.05$ declare -a a=($*)
bash-2.05$ echo ${a[*]}
3 4 5
bash-2.05$ foo=a
bash-2.05$ declare -a $foo=(6 7 8)
bash-2.05$ echo ${a[*]}
6 7 8
bash-2.05$ declare -a $foo=($*)
bash: declare: a: cannot assign to array variables in this way
bash: declare: `4': not a valid identifier
bash: declare: `5)': not a valid identifier
bash-2.05$ set 1 2 3
bash-2.05$ declare -a a=($@)
bash-2.05$ echo ${a[$*]}
bash: 1 2 3: syntax error in expression (error token is "2 3")
bash-2.05$ declare -a $foo=($@)
bash: declare: a: cannot assign to array variables in this way
bash: declare: `2': not a valid identifier
bash: declare: `3)': not a valid identifier
bash-2.05$ exit
exit
$ exit

script done on Mon Dec  3 16:31:42 2001



reply via email to

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