Open knrafto opened 7 years ago
Found another one, in this job: https://travis-ci.org/pbiggar/language-bash/jobs/161995727
brace expansion: FAIL (0.10s)
*** Failed! Assertion failed (after 69 tests):
"a,\\}}{a\\{,w\\}}{}l}{{xaky\\{\\ \\,\\,tuqmg}}z\\{,}asik{ng\\,"
Use --quickcheck-replay '68 TFGenR 1BCE489E03A1DF8763BEBE7128281A981FBC02700490D72F1B17CB17703ECB89 0 31 5 0' to reproduce.
From a failed test case I worked out a minimal example: "{a,b}{},c}"
Bash expands this to a{},c} b{},c}
.
Our expansion is a} ac b} bc
.
I suspect the following:
Bash scans the expression and expands {a,b}
. Since {}
is not a valid brace expansion it's left untouched and since the remaining ,c}
lacks an opening brace it's considered to be part of the postscript, too. Hence Bash expands {a,b}
with postscript {},c}
.
We interpret {},c}
as a brace expansion.
Interestingly {},c}
(without the {a,b}
) yields the same in both systems.
Can anyone confirm that?
After skimming the source code I think Bash works like I wrote in the last comment:
The interesting part of the source.
That seems right. However bash expands a{},c}
to a} ac
(which we do as well) so there's more to it.
I think this is the rule we don't implement right: https://git.savannah.gnu.org/cgit/bash.git/tree/braces.c#n710 To get this to work in parsec, we may need to keep state to be able to look back at the last character.
Actually maybe not, in {a,b}{},c}
there's no whitespace that precedes the {}
QuickCheck found this in this job