Permalink
Please sign in to comment.
Browse files
Integrate brace detection and expansion.
Brace detection changes a CompoundWord node to a BracedWordTree node.
Brace expansion expands it using the "Cartesian product" algorithm back
into an *array* of CompoundWord.
This is relevant in three contexts:
- commands: echo -{a,b}- other
- for loops: for i in -{a,b}- other; do echo $i; done
- arrays: array=({a,b} other)
So I inserted BraceDetectAll in osh/cmd_parse.py and osh/word_parse.py;
and BraceExpandAll in core/word_eval.py and core/cmd_exec.py.
I also fixed tilde expansion in all three contexts and added tests.
Changes to the algorithm in braces.py:
- Fixed bug where alternatives like {a,b}{c,d} were expanded in the
wrong order. The first one varies the slowest, and the last the
fastest: ac ad bc bd.
- Fix error cases like {foo}
- Use _StackFrame to simplify the code
Testing:
- Add a comparison of count.sh to gold-test.sh, so we're testing the
brace expansion in our own repo.
- Add date and oil version information to spec tests.
Other:
- Fixed a typo in evaluation of EscapedLiteralPart, which fixed a bunch
of tests. (--osh-allowed-failures bumped down in several places.)
- Rename AltPart to BracedAltPart, NumRangePart to BracedNumRangePart.- Loading branch information...
Showing
with
211 additions
and 173 deletions.
- +1 −1 asdl/py_meta.py
- +81 −40 core/braces.py
- +13 −8 core/braces_test.py
- +7 −3 core/cmd_exec.py
- +11 −0 core/word.py
- +4 −23 core/word_eval.py
- +6 −0 gold-test.sh
- +13 −73 osh/cmd_parse.py
- +13 −4 osh/osh.asdl
- +8 −4 osh/word_parse.py
- +16 −8 spec.sh
- +11 −0 tests/array.test.sh
- +13 −9 tests/brace-expansion.test.sh
- +14 −0 tests/loop.test.sh
Oops, something went wrong.
0 comments on commit
700c223