env.cpp: correctly check variable_can_be_array

Closes #1746.
This commit is contained in:
David Adam 2014-10-08 09:51:49 +08:00
parent 72f5ab3186
commit 14724401ff
3 changed files with 7 additions and 1 deletions

View file

@ -487,7 +487,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */)
wcstring key = key_and_val.substr(0, eql); wcstring key = key_and_val.substr(0, eql);
if (is_read_only(key) || is_electric(key)) continue; if (is_read_only(key) || is_electric(key)) continue;
wcstring val = key_and_val.substr(eql + 1); wcstring val = key_and_val.substr(eql + 1);
if (variable_can_be_array(val)) if (variable_can_be_array(key))
{ {
std::replace(val.begin(), val.end(), L':', ARRAY_SEP); std::replace(val.begin(), val.end(), L':', ARRAY_SEP);
} }

View file

@ -244,4 +244,8 @@ env SHLVL=3foo ../fish -c 'echo SHLVL: $SHLVL'
env SHLVL="3 " ../fish -c 'echo SHLVL: $SHLVL' env SHLVL="3 " ../fish -c 'echo SHLVL: $SHLVL'
env SHLVL=" 3" ../fish -c 'echo SHLVL: $SHLVL' env SHLVL=" 3" ../fish -c 'echo SHLVL: $SHLVL'
# Test transformation of inherited variables
env DISPLAY="localhost:0.0" ../fish -c 'echo Elements in DISPLAY: (count $DISPLAY)'
env PATH="/bin:/sbin:/usr/bin:/usr/sbin" ../fish -c 'echo Elements in PATH: (count $PATH)'
true true

View file

@ -28,3 +28,5 @@ SHLVL: 1
SHLVL: 1 SHLVL: 1
SHLVL: 4 SHLVL: 4
SHLVL: 4 SHLVL: 4
Elements in DISPLAY: 1
Elements in PATH: 4