Skip to content

Conversation

@wolfv
Copy link
Member

@wolfv wolfv commented Nov 11, 2025

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

claude and others added 2 commits November 11, 2025 06:37
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants