Change how arrays and environment variables interact.

Prior to this change, inherited environment variables
would be split on colons, becoming an array. This change
eliminates that behavior. Now environment variables are
always split on the record separator character (ASCII 0x1e),
with the exception of a short whitelist of PATH, MANPATH,
CDPATH. Likewise, exported variables are also exported
delimited by rs, with the exception of the above whitelist.

Fixes #1374, also see #1656
This commit is contained in:
ridiculousfish
2014-10-12 15:01:35 -07:00
parent c3bacc78c7
commit c0b8e81b02
3 changed files with 17 additions and 18 deletions

View File

@@ -248,7 +248,9 @@ env SHLVL=" 3" ../fish -c 'echo SHLVL: $SHLVL'
env DISPLAY="localhost:0.0" ../fish -c 'echo Elements in DISPLAY: (count $DISPLAY)'
# We can't use PATH for this because the global configuration will modify PATH
# based on /etc/paths and /etc/paths.d.
# At the moment, most variables split on :. So we can use an arbitrary variable for this.
env FOO="one:two:three:four" ../fish -c 'echo Elements in FOO: (count $FOO)'
# Exported arrays should use record separator, with a few exceptions. So we can use an arbitrary variable for this.
env FOO=one\x1etwo\x1ethree\x1efour ../fish -c 'echo Elements in FOO: (count $FOO)'
# some must use colon separators!
set -lx MANPATH man1 man2 man3 ; env | grep MANPATH
true

View File

@@ -30,3 +30,4 @@ SHLVL: 4
SHLVL: 4
Elements in DISPLAY: 1
Elements in FOO: 4
MANPATH=man1:man2:man3