diff options
author | Kevin Ballard <kevin@sb.org> | 2014-07-13 13:21:06 -0700 |
---|---|---|
committer | Kevin Ballard <kevin@sb.org> | 2014-07-13 13:21:06 -0700 |
commit | 7b12fd26f3d0ec2fe655cd537fda21f760e92d11 (patch) | |
tree | f51e75a57b2e1f7d7368b16b62acf54e94a15cbd /env.cpp | |
parent | 387ec5c06ad43f2aa0276be039522bd678cac4db (diff) |
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.
Diffstat (limited to 'env.cpp')
-rw-r--r-- | env.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -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> */ |