bug-bash
[Top][All Lists]
Advanced

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

Array variables and variable indirection


From: Matthew Garrett
Subject: Array variables and variable indirection
Date: Thu, 8 Aug 2002 11:34:38 -0500 (EST)

Bash 2.05.0(1)-release
Slackware 8.0, Intel i386 hardware, Linux 2.4.18, libc 2.2.3
Compiler unknown, presumably GCC 2.95.3

It doens't seem to be possible to access array variables through variable
indirection.

> declare -a
declare -ar BASH_VERSINFO='([0]="2" [1]="05" [2]="0" [3]="1" [4]="release" 
[5]="i386-slackware-linux-gnu")'
[... delitia ...]
> array=BASH_VERSINFO
> echo ${array}
BASH_VERSINFO
> echo ${!array}
2
# so far, so good, ${!array} is acted on exactly like ${BASH_VERSINFO}
# would, which is the same as ${BASH_VERSINFO[0]} in this case.
> echo ${!array[*]}
2
# Now what's happening?
# Shouldn't that have been "2 05 0 1 release i386-slackware-linux-gnu",
# not "2"?
> echo ${!array[4]}

# Shouldn't that be "release", not a blank line?

--
Matthew Garrett
magarret@Indiana.edu




reply via email to

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