]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/nameref13.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / nameref13.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 -nt r=a
15
16 f()
17 {
18 declare a
19 declare -n r=a
20 declare -p a r
21 }
22
23 f
24 unset -f f
25
26 f()
27 {
28 declare a
29 declare -n r
30 r=a
31 declare -p a r
32 }
33 f
34 echo $?
35
36 unset -f f
37
38 P=12345
39 function foo
40 {
41 typeset -n r
42 typeset -n r=P
43 typeset -p r
44 }
45
46 foo
47 unset P foo
48
49 ref=outside
50
51 f()
52 {
53 unset var
54 declare -n ref=var
55 declare -n ref;
56 declare -p ref;
57 }
58 f
59
60 unset ref foo
61
62 typeset -n r=a
63
64 f()
65 {
66 typeset a
67 typeset -n r
68 typeset -n r
69 r=a
70
71 typeset -p a r
72 }
73 f
74 echo $?
75 unset -n r
76 unset -f f
77
78 function foo
79 {
80 typeset -n r
81 typeset -n r
82 typeset -p r
83 }
84
85 foo
86 unset -f foo
87
88
89 function foo
90 {
91 typeset r
92 typeset -n r
93 typeset -p r
94 }
95 foo
96 unset -f foo
97
98 foo()
99 {
100 typeset -n foo
101 typeset foo=12345
102 typeset -p foo
103 }
104 foo
105 unset -f foo
106
107 foo()
108 {
109 typeset -n foo
110 typeset -n foo=12345
111 typeset -p foo
112 }
113 foo
114 unset -f foo
115