feat: implement brace expansion as strict subset of bash#273
Open
feat: implement brace expansion as strict subset of bash#273
Conversation
This commit adds brace expansion support to the shell, implementing
a strict subset of bash's brace expansion functionality.
Supported features:
- Comma-separated lists: {a,b,c} → a b c
- Numeric sequences: {1..10} → 1 2 3 4 5 6 7 8 9 10
- Character sequences: {a..z} → a b c ... z
- Reverse sequences: {10..1} → 10 9 8 7 6 5 4 3 2 1
- Step sequences: {1..10..2} → 1 3 5 7 9
- Reverse step sequences: {10..1..2} → 10 8 6 4 2
- Empty elements: {a,,b} → a b
- Quoted braces don't expand: "{a,b,c}" → {a,b,c}
Implementation details:
- Added BRACE_EXPANSION grammar rule to grammar.pest
- Added BraceExpansion enum to parser.rs with List and Sequence variants
- Added WordPart::BraceExpansion variant
- Implemented expand_braces() and expand_sequence() functions
- Added comprehensive test suite in brace_expansion.sh
The implementation is a strict subset of bash, ensuring compatibility
while keeping the implementation simple and maintainable.
Fixes #242
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds brace expansion support to the shell, implementing a strict subset of bash's brace expansion functionality.
Supported features:
Implementation details:
The implementation is a strict subset of bash, ensuring compatibility while keeping the implementation simple and maintainable.
Fixes #242