mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Comment and test that we shouldn't copy for blocks
Seems important.
This commit is contained in:
parent
c1ea9c7025
commit
427b8f5c52
3 changed files with 14 additions and 0 deletions
|
@ -183,6 +183,8 @@ void var_stack_t::push(bool new_scope) {
|
||||||
|
|
||||||
// Copy local-exported variables
|
// Copy local-exported variables
|
||||||
auto top_node = top.get();
|
auto top_node = top.get();
|
||||||
|
// Only if we introduce a new shadowing scope
|
||||||
|
// i.e. not if it's just `begin; end` or "--no-scope-shadowing".
|
||||||
if (new_scope) {
|
if (new_scope) {
|
||||||
if (!(top_node == this->global_env)) {
|
if (!(top_node == this->global_env)) {
|
||||||
for (auto& var : top_node->env) {
|
for (auto& var : top_node->env) {
|
||||||
|
|
|
@ -257,6 +257,15 @@ set -lx var wuwuwu
|
||||||
__fish_test_local_export
|
__fish_test_local_export
|
||||||
echo $var
|
echo $var
|
||||||
|
|
||||||
|
# Test that we don't copy local-exports to blocks.
|
||||||
|
set -lx var foo
|
||||||
|
begin
|
||||||
|
echo $var
|
||||||
|
set var bar
|
||||||
|
echo $var
|
||||||
|
end
|
||||||
|
echo $var # should be "bar"
|
||||||
|
|
||||||
# clear for other shells
|
# clear for other shells
|
||||||
set -eU __fish_test_universal_variables_variable_foo
|
set -eU __fish_test_universal_variables_variable_foo
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ __fish_test_env17=UNSHADOWED
|
||||||
wuwuwu
|
wuwuwu
|
||||||
boo
|
boo
|
||||||
wuwuwu
|
wuwuwu
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
bar
|
||||||
Testing Universal Startup
|
Testing Universal Startup
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
|
|
Loading…
Reference in a new issue