fish-shell/tests/parameter_expansion.in
Fabian Homborg 967c1d51ee Only do brace expansion if they contain a variable or ","
Brace expansion with single words in it is quite useless - `HEAD@{0}`
expanding to `HEAD@0` breaks git.

So we complicate the rule slightly - if there is no variable expansion
or "," inside of braces, they are just treated as literal braces.

Note that this is technically backwards-incompatible, because

    echo foo{0}

will now print `foo{0}` instead of `foo0`. However that's a
technicality because the braces were literally useless in that case.

Our tests needed to be adjusted, but that's because they are meant to
exercise this in weird ways.

I don't believe this will break any code in practice.

Fixes #5869.
2019-05-19 18:23:27 +02:00

35 lines
848 B
Fish

# basic expansion test
echo {}
echo {apple}
echo {apple,orange}
# expansion tests with spaces
echo {apple, orange}
echo { apple, orange, banana }
# expansion with spaces and cartesian products
echo \'{ hello , world }\'
# expansion with escapes
for phrase in {good\,, beautiful ,morning}; echo -n "$phrase "; end | string trim;
for phrase in {goodbye\,,\ cruel\ ,world\n}; echo -n $phrase; end;
# whitespace within entries converted to spaces in a single entry
for foo in {a, hello
world }
echo \'$foo\'
end
# dual expansion cartesian product
echo { alpha, beta }\ {lambda, gamma }, | string replace -r ',$' ''
# expansion with subshells
for name in { (echo Meg), (echo Jo) }
echo $name
end
# subshells with expansion
for name in (for name in {Beth, Amy}; printf "$name\n"; end); printf "$name\n"; end
echo {{a,b}}
# vim: set ft=fish: