]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/new-exp9.sub
Bash-4.3 patch 7
[thirdparty/bash.git] / tests / new-exp9.sub
1 indirarray()
2 {
3 local intermediary
4 local sub
5
6 intermediary="${1}[@]"
7 local -a leftValue=("${!intermediary}")
8
9 local -a leftSub
10 eval leftSub=(\"\${!${1}[@]}\")
11
12 echo "$1" Value = ${leftValue[@]}
13 echo "$1" Sub = ${leftSub[@]}
14 }
15
16 a=(1 2 3 4 5)
17 b=(a b c d e)
18
19 c=([0]=10 [2]=20 [4]=40 [8]=80)
20
21 indirarray a
22 indirarray b
23 indirarray c
24
25 ref=a
26 tmp="$ref[@]"
27 printf "<%s> " "${!tmp}"; echo # Iterate whole array.
28
29 ref=c
30 tmp="$ref[@]"
31 printf "<%s> " "${!tmp}"; echo # Iterate whole array.