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