mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
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;
|
result.global_modified = true;
|
||||||
} else if (query.local) {
|
} else if (query.local) {
|
||||||
result.status = remove_from_chain(locals_, key) ? ENV_OK : ENV_NOT_FOUND;
|
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 {
|
} else {
|
||||||
DIE("Unknown scope");
|
DIE("Unknown scope");
|
||||||
}
|
}
|
||||||
|
@ -806,3 +806,17 @@ end
|
|||||||
test-function-scope
|
test-function-scope
|
||||||
echo $funcvar $funcvar2
|
echo $funcvar $funcvar2
|
||||||
# CHECK:
|
# 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