2017-08-02 03:58:40 +00:00
|
|
|
# Test various behaviors of the `set` command.
|
|
|
|
|
|
|
|
logmsg Verify behavior of `set --show` given an invalid var name
|
|
|
|
set --show 'argle bargle'
|
|
|
|
|
2017-08-04 04:25:20 +00:00
|
|
|
logmsg Verify behavior of `set --show`
|
2017-08-16 20:39:48 +00:00
|
|
|
set semiempty ''
|
|
|
|
set --show semiempty
|
|
|
|
|
2017-08-02 03:58:40 +00:00
|
|
|
set -U var1 hello
|
|
|
|
set --show var1
|
|
|
|
|
|
|
|
set -l var1
|
|
|
|
set -g var1 goodbye "and don't come back"
|
|
|
|
set --show var1
|
|
|
|
|
|
|
|
set -g var2
|
|
|
|
set --show _unset_var var2
|
2017-08-04 06:57:36 +00:00
|
|
|
|
|
|
|
logmsg Appending works
|
|
|
|
set -g var3a a b c
|
|
|
|
set -a var3a
|
|
|
|
set -a var3a d
|
|
|
|
set -a var3a e f
|
|
|
|
set --show var3a
|
|
|
|
set -g var3b
|
|
|
|
set -a var3b
|
|
|
|
set --show var3b
|
|
|
|
set -g var3c
|
|
|
|
set -a var3c 'one string'
|
|
|
|
set --show var3c
|
|
|
|
|
|
|
|
logmsg Prepending works
|
|
|
|
set -g var4a a b c
|
|
|
|
set -p var4a
|
|
|
|
set -p var4a d
|
|
|
|
set -p var4a e f
|
|
|
|
set --show var4a
|
|
|
|
set -g var4b
|
|
|
|
set -p var4b
|
|
|
|
set --show var4b
|
|
|
|
set -g var4c
|
|
|
|
set -p var4c 'one string'
|
|
|
|
set --show var4c
|
|
|
|
|
|
|
|
logmsg Appending and prepending at same time works
|
|
|
|
set -g var5 abc def
|
|
|
|
set -a -p var5 0 x 0
|
|
|
|
set --show var5
|
2017-08-20 04:39:21 +00:00
|
|
|
|
|
|
|
logmsg Setting local scope when no local scope of the var uses the closest scope
|
|
|
|
set -g var6 ghi jkl
|
|
|
|
begin
|
|
|
|
set -l -a var6 mno
|
|
|
|
set --show var6
|
|
|
|
end
|
2018-03-25 06:32:55 +00:00
|
|
|
|
|
|
|
logmsg Exporting works
|
|
|
|
set -x TESTVAR0
|
|
|
|
set -x TESTVAR1 a
|
|
|
|
set -x TESTVAR2 a b
|
|
|
|
env | grep TESTVAR | cat -v
|
2018-03-31 21:57:24 +00:00
|
|
|
|
|
|
|
logmsg if/for/while scope
|
|
|
|
function test_ifforwhile_scope
|
|
|
|
if set -l ifvar1 (true && echo val1) ; end
|
|
|
|
if set -l ifvar2 (echo val2 && false) ; end
|
|
|
|
if false ; else if set -l ifvar3 (echo val3 && false) ; end
|
|
|
|
while set -l whilevar1 (echo val3 ; false) ; end
|
|
|
|
set --show ifvar1 ifvar2 ifvar3 whilevar1
|
|
|
|
end
|
|
|
|
test_ifforwhile_scope
|