]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/nameref18.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / nameref18.sub
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 #
14 declare -n ref=XXX[0]
15 mapfile ref <<< $'1\n2'
16 declare -p XXX[0]
17
18 unset -n ref
19
20 declare -n ref=XXX[0]
21 declare -A ref
22 ref[foo]=bar
23 declare -p XXX[0]
24
25 unset -n ref
26 unset XXX
27
28 typeset -n ref=XXX[0]
29 typeset ref=4
30
31 typeset -p ref XXX
32
33 unset -n ref
34 unset XXX
35
36 declare -n ref=XXX[0]
37 ref+=([2]=x)
38 declare -p ref XXX[0]
39 unset -n ref
40
41 declare -n ref=XXX[0]
42 read -a ref <<< "A B C"
43 declare -p XXX[0]
44 unset -n ref
45
46 declare -n ref=XXX[0]
47 unset ref
48 ref=()
49 declare -p ref
50
51 coproc ref { :; }; declare -p ${!ref}
52 wait
53
54 unset -n ref
55
56 declare -n ref=var[123]
57 unset ref
58 declare ref=
59 declare -p ref ${!ref} var
60
61 unset ref
62 declare ref+=
63 declare -p ref ${!ref} var
64
65 declare +t ref
66 ref=X
67 declare -p ref ${!ref} var
68
69 unset -n ref
70 unset var
71
72 arr=(1 2 3)
73
74 indir='arr[@]'
75 declare -n ref='arr[@]'
76
77 recho "${!indir}"
78 recho ${!indir}
79
80 recho "$ref"
81 recho $ref
82
83 recho "${!indir}$ref"