From 1d5cace9db9aef76f26b2d7ba54bbb76443b00b2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 20:33:23 +0200 Subject: Adding upstream version 5.0. Signed-off-by: Daniel Baumann --- tests/nameref3.sub | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/nameref3.sub (limited to 'tests/nameref3.sub') diff --git a/tests/nameref3.sub b/tests/nameref3.sub new file mode 100644 index 0000000..5790291 --- /dev/null +++ b/tests/nameref3.sub @@ -0,0 +1,37 @@ +# nameref requires changes to unset +bar=one +typeset -n foo=bar + +# normal unset unsets only variable nameref references +# need unset -n to unset nameref itself +unset foo +echo "expect " +recho ${bar-unset} +echo "expect " +recho ${foo-unset} +echo "expect " +recho ${!foo} +unset -n foo +echo "expect " +recho "${!foo-unset}" + +readonly bar=two +typeset -n foo=bar + +unset foo # this should fail because bar is readonly + +echo "expect " +echo ${bar-unset} +echo "expect " +echo ${foo-unset} + +# one question is what happens when you unset the underlying variable +qux=three +typeset -n ref +ref=qux + +echo $ref +unset qux +echo ${ref-unset} +qux=four +echo ${ref-unset} -- cgit v1.2.3