mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
59f0261dba
Fish keywords can be quoted and split across lines. Prior to this change `fish_indent` would retain such odd, obfuscated, formatting. This change results in all keywords being converted to their canonical form. This required fixing a bug: the keyword member of parse_node_t wasn't being populated. This hadn't been noticed prior to now because it wasn't used. Fixes #2921
106 lines
1.4 KiB
Fish
106 lines
1.4 KiB
Fish
echo Test1
|
|
echo -n '
|
|
begin
|
|
echo hi
|
|
|
|
|
|
end | cat | cat | begin ; echo hi ; end | begin ; begin ; echo hi ; end ; end arg
|
|
' | ../test/root/bin/fish_indent
|
|
|
|
echo \nTest2
|
|
echo -n '
|
|
switch aloha
|
|
|
|
case alpha
|
|
echo sup
|
|
|
|
case beta gamma
|
|
echo hi
|
|
|
|
end
|
|
' | ../test/root/bin/fish_indent
|
|
|
|
echo \nTest3
|
|
echo -n '
|
|
function hello_world
|
|
|
|
'begin'
|
|
echo hi
|
|
end | cat
|
|
|
|
echo sup; echo sup
|
|
echo hello;
|
|
|
|
echo hello
|
|
end
|
|
' | ../test/root/bin/fish_indent
|
|
|
|
echo \nTest4
|
|
echo -n '
|
|
echo alpha #comment1
|
|
#comment2
|
|
|
|
#comment3
|
|
for i in abc #comment1
|
|
#comment2
|
|
echo hi
|
|
end
|
|
|
|
switch foo #abc
|
|
# bar
|
|
case bar
|
|
echo baz\
|
|
qqq
|
|
case "*"
|
|
echo sup
|
|
end' | ../test/root/bin/fish_indent
|
|
|
|
echo \nTest5
|
|
echo -n '
|
|
if true
|
|
else if false
|
|
echo alpha
|
|
switch beta
|
|
case gamma
|
|
echo delta
|
|
end
|
|
end
|
|
' | ../test/root/bin/fish_indent -i
|
|
|
|
echo \nTest6
|
|
# Test errors
|
|
echo -n '
|
|
begin
|
|
echo hi
|
|
else
|
|
echo bye
|
|
end; echo alpha "
|
|
' | ../test/root/bin/fish_indent
|
|
|
|
echo \nTest7
|
|
# issue 1665
|
|
echo -n '
|
|
if begin ; false; end; echo hi ; end
|
|
while begin ; false; end; echo hi ; end
|
|
' | ../test/root/bin/fish_indent
|
|
|
|
echo \nTest redir formatting
|
|
# issue 2899
|
|
echo -n '
|
|
echo < stdin >>appended yes 2>&1 no > stdout maybe 2>& 4 | cat 2>| cat
|
|
' | ../test/root/bin/fish_indent
|
|
|
|
echo \nTest normalization of keywords
|
|
# issue 2921
|
|
echo -n '
|
|
i\
|
|
f true
|
|
echo yes
|
|
en\
|
|
d
|
|
|
|
"whil\
|
|
e" true
|
|
"builtin" yes
|
|
en"d"
|
|
' | ../test/root/bin/fish_indent
|