fish-shell/tests/set.out
ridiculousfish 3f3b3a7006 Export arrays as colon delimited, and support path-style variables
This commit begins to bake in a notion of path-style variables.

Prior to this fix, fish would export arrays as ASCII record separator
delimited, except for a whitelist (PATH, CDPATH, MANPATH). This is
surprising and awkward for other programs to deal with, and there's no way
to get similar behavior for other variables like GOPATH or LD_LIBRARY_PATH.

This commit does the following:

1. Exports all arrays as colon delimited strings, instead of RS.

2. Introduces a notion of "path variable." A path variable will be
"colon-delimited" which means it gets colon-separated in quoted expansion,
and automatically splits on colons. In this commit we only do the exporting
part.

Colons are not escaped in exporting; this is deliberate to support uses
like

    `set -x PYTHONPATH "/foo:/bar"`

which ought to work (and already do, we don't want  to make a compat break
here).
2018-10-19 17:29:39 -07:00

131 lines
3.8 KiB
Text

####################
# Verify behavior of `set --show` given an invalid var name
####################
# Verify behavior of `set --show`
$semiempty: not set in local scope
$semiempty: set in global scope, unexported, with 1 elements
$semiempty[1]: length=0 value=||
$semiempty: not set in universal scope
$var1: not set in local scope
$var1: not set in global scope
$var1: set in universal scope, unexported, with 1 elements
$var1[1]: length=5 value=|hello|
$var1: set in local scope, unexported, with 0 elements
$var1: set in global scope, unexported, with 2 elements
$var1[1]: length=7 value=|goodbye|
$var1[2]: length=19 value=|and don\'t come back|
$var1: set in universal scope, unexported, with 1 elements
$var1[1]: length=5 value=|hello|
$_unset_var: not set in local scope
$_unset_var: not set in global scope
$_unset_var: not set in universal scope
$var2: not set in local scope
$var2: set in global scope, unexported, with 0 elements
$var2: not set in universal scope
####################
# Appending works
$var3a: not set in local scope
$var3a: set in global scope, unexported, with 6 elements
$var3a[1]: length=1 value=|a|
$var3a[2]: length=1 value=|b|
$var3a[3]: length=1 value=|c|
$var3a[4]: length=1 value=|d|
$var3a[5]: length=1 value=|e|
$var3a[6]: length=1 value=|f|
$var3a: not set in universal scope
$var3b: not set in local scope
$var3b: set in global scope, unexported, with 0 elements
$var3b: not set in universal scope
$var3c: not set in local scope
$var3c: set in global scope, unexported, with 1 elements
$var3c[1]: length=10 value=|one string|
$var3c: not set in universal scope
####################
# Prepending works
$var4a: not set in local scope
$var4a: set in global scope, unexported, with 6 elements
$var4a[1]: length=1 value=|e|
$var4a[2]: length=1 value=|f|
$var4a[3]: length=1 value=|d|
$var4a[4]: length=1 value=|a|
$var4a[5]: length=1 value=|b|
$var4a[6]: length=1 value=|c|
$var4a: not set in universal scope
$var4b: not set in local scope
$var4b: set in global scope, unexported, with 0 elements
$var4b: not set in universal scope
$var4c: not set in local scope
$var4c: set in global scope, unexported, with 1 elements
$var4c[1]: length=10 value=|one string|
$var4c: not set in universal scope
####################
# Appending and prepending at same time works
$var5: not set in local scope
$var5: set in global scope, unexported, with 8 elements
$var5[1]: length=1 value=|0|
$var5[2]: length=1 value=|x|
$var5[3]: length=1 value=|0|
$var5[4]: length=3 value=|abc|
$var5[5]: length=3 value=|def|
$var5[6]: length=1 value=|0|
$var5[7]: length=1 value=|x|
$var5[8]: length=1 value=|0|
$var5: not set in universal scope
####################
# Setting local scope when no local scope of the var uses the closest scope
$var6: set in local scope, unexported, with 3 elements
$var6[1]: length=3 value=|ghi|
$var6[2]: length=3 value=|jkl|
$var6[3]: length=3 value=|mno|
$var6: set in global scope, unexported, with 2 elements
$var6[1]: length=3 value=|ghi|
$var6[2]: length=3 value=|jkl|
$var6: not set in universal scope
####################
# Exporting works
TESTVAR0=
TESTVAR1=a
TESTVAR2=a b
####################
# if/for/while scope
$ifvar1: set in local scope, unexported, with 1 elements
$ifvar1[1]: length=4 value=|val1|
$ifvar1: not set in global scope
$ifvar1: not set in universal scope
$ifvar2: set in local scope, unexported, with 1 elements
$ifvar2[1]: length=4 value=|val2|
$ifvar2: not set in global scope
$ifvar2: not set in universal scope
$ifvar3: set in local scope, unexported, with 1 elements
$ifvar3[1]: length=4 value=|val3|
$ifvar3: not set in global scope
$ifvar3: not set in universal scope
$whilevar1: set in local scope, unexported, with 1 elements
$whilevar1[1]: length=4 value=|val3|
$whilevar1: not set in global scope
$whilevar1: not set in universal scope