mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 11:21:15 -03:00
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:
@@ -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
|
||||
|
||||
@@ -30,3 +30,4 @@ SHLVL: 4
|
||||
SHLVL: 4
|
||||
Elements in DISPLAY: 1
|
||||
Elements in FOO: 4
|
||||
MANPATH=man1:man2:man3
|
||||
|
||||
Reference in New Issue
Block a user