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.
This commit is contained in:
Kevin Ballard 2014-07-12 00:53:23 -07:00
parent 8c89e6bce5
commit 383aaa236e

View file

@ -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))
{