aboutsummaryrefslogtreecommitdiffhomepage
path: root/env.cpp
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-07-12 00:53:23 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-07-12 00:53:23 -0700
commit383aaa236e7bb0c03cd1b8afe23b9c2e2712a8f2 (patch)
treeceec2fc88f49d559b5a5af73443551064930e2f1 /env.cpp
parent8c89e6bce5f38b51cfe227fd8cecb66fa43fc849 (diff)
Don't allow readonly/electric values to come in through the env
When initializing fish, ignore any inherited environment variables that match any of the readonly or electric variable names. This prevents really weird behavior when e.g. fish is launched with COLUMNS already set to something. In that case, testing $COLUMNS within fish behaves normally, but any subprocesses get the value that fish itself had inherited.
Diffstat (limited to 'env.cpp')
-rw-r--r--env.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/env.cpp b/env.cpp
index abf1973e..2246555d 100644
--- a/env.cpp
+++ b/env.cpp
@@ -510,11 +510,13 @@ void env_init(const struct config_paths_t *paths /* or NULL */)
if (eql == wcstring::npos)
{
// no equals found
- env_set(key_and_val, L"", ENV_EXPORT);
+ if (is_read_only(key_and_val) || is_electric(key_and_val)) continue;
+ env_set(key_and_val, L"", ENV_EXPORT | ENV_GLOBAL);
}
else
{
wcstring key = key_and_val.substr(0, eql);
+ if (is_read_only(key) || is_electric(key)) continue;
wcstring val = key_and_val.substr(eql + 1);
if (variable_can_be_array(val))
{