From bbc5194773642292b1cabade5bd965b9e28d40e8 Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Thu, 8 Oct 2026 00:49:16 +0000 Subject: [PATCH] test(spec): unset scope cases from the bash oracle The behavior landed with the declaration engine (#2597); these cases pin it: a callee's `unset` uncovers the caller's binding for scalars and arrays, and a local unset in its own scope stays invisible for the rest of the call. Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA --- .../spec_cases/bash/unset-local-scope.test.sh | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 crates/bashkit/tests/spec_cases/bash/unset-local-scope.test.sh diff --git a/crates/bashkit/tests/spec_cases/bash/unset-local-scope.test.sh b/crates/bashkit/tests/spec_cases/bash/unset-local-scope.test.sh new file mode 100644 index 000000000..f95406ed1 --- /dev/null +++ b/crates/bashkit/tests/spec_cases/bash/unset-local-scope.test.sh @@ -0,0 +1,36 @@ +### unset_local_exposes_global +f() { local v=f; g; echo "f sees ${v:-none}"; } +g() { echo "g sees ${v:-none}"; unset v; echo "after unset ${v:-none}"; } +v=global; f; echo "global: $v" +### expect +g sees f +after unset global +f sees global +global: global +### end + +### unset_global_from_function +f() { unset v; echo "in f ${v:-none}"; } +v=global; f; echo "after ${v:-none}" +### expect +in f none +after none +### end + +### unset_local_in_own_function +f() { local v=f; unset v; echo "${v:-none}"; } +v=global; f; echo "$v" +### expect +none +global +### end + +### unset_local_array_exposes_global +f() { local -a a=(x y); g; echo "f: ${a[*]}"; } +g() { unset a; echo "g: ${a[*]:-none}"; } +a=(1 2 3); f; echo "global: ${a[*]}" +### expect +g: 1 2 3 +f: 1 2 3 +global: 1 2 3 +### end