diff options
author | Kevin Ballard <kevin@sb.org> | 2014-07-12 00:53:23 -0700 |
---|---|---|
committer | Kevin Ballard <kevin@sb.org> | 2014-07-12 00:53:23 -0700 |
commit | 383aaa236e7bb0c03cd1b8afe23b9c2e2712a8f2 (patch) | |
tree | ceec2fc88f49d559b5a5af73443551064930e2f1 /env.cpp | |
parent | 8c89e6bce5f38b51cfe227fd8cecb66fa43fc849 (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.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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)) { |