mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
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:
parent
8c89e6bce5
commit
383aaa236e
1 changed files with 3 additions and 1 deletions
4
env.cpp
4
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))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue