]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/nameref11.sub
bash-5.1 distribution sources and documentation
[thirdparty/bash.git] / tests / nameref11.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 r=/; declare -n r ; unset r
15 declare -n r=/ ; unset -n r
16 declare -n r; r=/ ; unset -n r
17 declare -n r; declare r=/ ; unset -n r
18 declare -n r; for r in /; do :; done ; unset -n r
19 declare -n r; select r in /; do :; done <<< 1; echo x; echo $r ; unset -n r
20 declare -n r; ((r=0)) ; unset -n r
21 ((r=0)); declare -n r ; unset -n r
22 r=/ declare -n r ; unset -n r
23 f() { declare -n r; }; r=/ f ; unset r
24 f() { echo $r; }; declare -n r; r=/ f ; unset -n r
25 declare -n r; : ${r:=/} ; unset -n r
26 declare -n r; exec {r}>/dev/null ; unset -n r
27 declare -n r; coproc r { :; }; echo $r ; unset r ; wait
28 declare -r RO=x; r=$RO; declare -n r; x=y; declare -n RO; RO=z; declare -p RO; echo "$RO"
29 s=/; declare -n r=s; declare -n s; echo $r ; unset -n r ; unset -n s
30 declare -n r=s; declare -n s; s=/ ; unset -n r; unset -n s
31 declare -n r; getopts x r -h ; unset r; unset -n r
32 declare -n r; mapfile r < /dev/null ; declare -p r; unset r ; unset -n r
33 mapfile r < /dev/null; declare -n r ; unset r ; unset -n r
34 declare -n r; printf -v r / ; unset -n r
35
36 declare -n r; r="" ; unset -n r
37 declare -n r="" ; unset -n r
38 declare -n r; : ${r=} ; unset -n r
39 declare -n r; printf -v r '' ; unset -n r
40 r=""; declare -n r ; unset -n r
41 export r
42
43 # coproc tests, since coproc sets and unsets variables
44 declare -r ROVAR=42
45 declare -p ROVAR; coproc ROVAR { :; }; wait; declare -p ROVAR
46
47 echo ${@:0}; coproc @ { :; }; wait ; echo ${@:0}
48
49 declare -n ref=x; coproc ref { :; }; wait ; declare -p ref
50 unset -n ref ; unset ref
51
52 declare -r RO RO_PID; coproc RO { :; }; declare -p RO_PID; wait; declare -p RO RO_PID
53
54 declare -r RO2=a; declare -n ref_PID=RO2; coproc ref { :; }; wait; declare -p RO2
55
56 unset x y
57 set -- one two three
58
59 y=2
60 typeset -n x=y
61 echo ${x}
62
63 unset -n x
64
65 typeset -n y
66 echo $y
67
68 unset -n y
69
70 typeset -n y
71 y=2
72 echo ${y}
73
74 declare -n foo=bar
75 echo ${!foo[2]}
76 echo ${!bar}