Allow erasing vars via function-scope
This triggered an assert because the remove code had no idea how to find the function scope. Oops!
This commit is contained in:
parent
c7c67755d3
commit
0059192f61
@ -1251,6 +1251,13 @@ mod_result_t env_stack_impl_t::remove(const wcstring &key, int mode) {
|
||||
result.global_modified = true;
|
||||
} else if (query.local) {
|
||||
result.status = remove_from_chain(locals_, key) ? ENV_OK : ENV_NOT_FOUND;
|
||||
} else if (query.function) {
|
||||
auto node = locals_;
|
||||
while (node->next) {
|
||||
node = node->next;
|
||||
if (node->new_scope) break;
|
||||
}
|
||||
result.status = remove_from_chain(node, key) ? ENV_OK : ENV_NOT_FOUND;
|
||||
} else {
|
||||
DIE("Unknown scope");
|
||||
}
|
||||
|
@ -806,3 +806,17 @@ end
|
||||
test-function-scope
|
||||
echo $funcvar $funcvar2
|
||||
# CHECK:
|
||||
|
||||
function erase-funcvar
|
||||
set -l banana 1
|
||||
begin
|
||||
set -l banana 2
|
||||
set -ef banana
|
||||
echo $banana
|
||||
# CHECK: 2
|
||||
end
|
||||
echo $banana
|
||||
# CHECK:
|
||||
end
|
||||
|
||||
erase-funcvar
|
||||
|
Loading…
x
Reference in New Issue
Block a user