mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-16 01:38:24 +00:00
4b079e16e5
Variables set in if and while conditions are in the enclosing block, not the if/while statement block. For example: if set -l var (somecommand) ; end echo $var will now work as expected. Fixes #4820. Fixes #1212.
131 lines
3.8 KiB
Text
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
|
|
|