From a663c11e5012dafd387cb5a73650bb5a59273bea Mon Sep 17 00:00:00 2001 From: Andy Chu Date: Fri, 17 Apr 2020 10:21:33 -0700 Subject: [PATCH] [spec/builtin-vars] Simple case to show 'local unset cell' semantics. Related to #706. --- spec/builtin-vars.test.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/builtin-vars.test.sh b/spec/builtin-vars.test.sh index 30ee194020..cba51ed639 100644 --- a/spec/builtin-vars.test.sh +++ b/spec/builtin-vars.test.sh @@ -368,6 +368,28 @@ level2=yy level2= ## END +#### unset of local reveals variable in higher scope + +# Oil has a RARE behavior here (matching yash and mksh), but at least it's +# consistent. + +x=global +f() { + local x=foo + echo x=$x + unset x + echo x=$x +} +f +## STDOUT: +x=foo +x=global +## END +## OK dash/bash/zsh/ash STDOUT: +x=foo +x= +## END + #### Unset invalid variable name unset % echo status=$?