mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 03:01:15 -03:00
Change how we separate toplevel and global scopes
Instead of introducing a new local scope at the point of `set`, merely
push a new local scope at the end of env_init(). This means we have a
single toplevel local scope across the lifetime of the fish process,
which means that
set -l foo bar
echo $foo
behaves as expected, without modifying the global environment.
This commit is contained in:
18
env.cpp
18
env.cpp
@@ -593,6 +593,14 @@ void env_init(const struct config_paths_t *paths /* or NULL */)
|
||||
|
||||
/* Set fish_bind_mode to "default" */
|
||||
env_set(FISH_BIND_MODE_VAR, DEFAULT_BIND_MODE, ENV_GLOBAL);
|
||||
|
||||
/*
|
||||
Now that the global scope is fully initialized, add a toplevel local
|
||||
scope. This same local scope will persist throughout the lifetime of the
|
||||
fish process, and it will ensure that `set -l` commands run at the
|
||||
command-line don't affect the global scope.
|
||||
*/
|
||||
env_push(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1195,16 +1203,6 @@ void env_pop()
|
||||
}
|
||||
}
|
||||
|
||||
bool env_ensure_local_scope()
|
||||
{
|
||||
if (top == global_env)
|
||||
{
|
||||
env_push(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
Function used with to insert keys of one table into a set::set<wcstring>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user