]>
Commit | Line | Data |
---|---|---|
ac50fbac CR |
1 | # nameref requires changes to unset |
2 | bar=one | |
3 | typeset -n foo=bar | |
4 | ||
5 | # normal unset unsets only variable nameref references | |
6 | # need unset -n to unset nameref itself | |
7 | unset foo | |
8 | echo "expect <unset>" | |
9 | recho ${bar-unset} | |
10 | echo "expect <unset>" | |
11 | recho ${foo-unset} | |
12 | echo "expect <bar>" | |
13 | recho ${!foo} | |
14 | unset -n foo | |
15 | echo "expect <unset>" | |
16 | recho "${!foo-unset}" | |
17 | ||
18 | readonly bar=two | |
19 | typeset -n foo=bar | |
20 | ||
21 | unset foo # this should fail because bar is readonly | |
22 | ||
23 | echo "expect <two>" | |
24 | echo ${bar-unset} | |
25 | echo "expect <two>" | |
26 | echo ${foo-unset} | |
27 | ||
28 | # one question is what happens when you unset the underlying variable | |
29 | qux=three | |
30 | typeset -n ref | |
31 | ref=qux | |
32 | ||
33 | echo $ref | |
34 | unset qux | |
35 | echo ${ref-unset} | |
36 | qux=four | |
37 | echo ${ref-unset} |