mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
b25f72f391
This tries to see if quotes guard some expansion from happening. If it detects a "weird" character it'll leave the quotes in place, even in some cases where it might not trigger. So for i in 'c' 'color' turns into for i in c color The rationale here is that these quotes are useless, wasting space (and line length), but more importantly that they are superstitions. They don't do anything, but look like they do. The counter argument is that they can be kept in case of later changes, or that they make the intent clear - "this is supposed to be a string we pass".
138 lines
1.2 KiB
Text
138 lines
1.2 KiB
Text
Test1
|
|
|
|
begin
|
|
echo hi
|
|
|
|
|
|
end | cat | cat | begin
|
|
echo hi
|
|
end | begin
|
|
begin
|
|
echo hi
|
|
end
|
|
end arg
|
|
|
|
Test2
|
|
|
|
switch aloha
|
|
|
|
case alpha
|
|
echo sup
|
|
|
|
case beta gamma
|
|
echo hi
|
|
|
|
end
|
|
|
|
Test3
|
|
|
|
function hello_world
|
|
|
|
begin
|
|
echo hi
|
|
end | cat
|
|
|
|
echo sup
|
|
echo sup
|
|
echo hello
|
|
|
|
echo hello
|
|
end
|
|
|
|
Test4
|
|
|
|
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
|
|
Test5
|
|
|
|
if true
|
|
else if false
|
|
echo alpha
|
|
switch beta
|
|
case gamma
|
|
echo delta
|
|
end
|
|
end
|
|
|
|
Test6
|
|
|
|
begin
|
|
echo hi
|
|
else
|
|
echo bye
|
|
end
|
|
echo alpha "
|
|
|
|
Test7
|
|
|
|
if begin
|
|
false
|
|
end
|
|
echo hi
|
|
end
|
|
while begin
|
|
false
|
|
end
|
|
echo hi
|
|
end
|
|
|
|
Test redir formatting
|
|
|
|
echo <stdin >>appended yes 2>&1 no >stdout maybe 2>&4 | cat 2>| cat
|
|
|
|
Test normalization of keywords
|
|
|
|
i\
|
|
f true
|
|
echo yes
|
|
en\
|
|
d
|
|
|
|
while true
|
|
builtin yes
|
|
end
|
|
|
|
alpha | \
|
|
beta
|
|
|
|
gamma | \
|
|
# comment3
|
|
delta
|
|
|
|
if true
|
|
echo abc
|
|
end
|
|
|
|
if false # comment4
|
|
and true && false
|
|
echo abc
|
|
end
|
|
|
|
echo hi |
|
|
|
|
echo bye
|
|
a
|
|
echo
|
|
echo
|
|
a; and b
|
|
a
|
|
and b
|
|
a
|
|
and b
|
|
a
|
|
b
|