Skip to content

fix(interpreter): brace expansion before other expansions - #2579

Merged
chaliy merged 1 commit into
mainfrom
claude/shell-gaps
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/shell-gaps

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

Brace expansion now runs first, on the parsed word, as in bash. Only unquoted literal text takes part; variables, substitutions and quoted segments are opaque. The lexer no longer has ad hoc readers for words starting with { (they ignored quotes and split words).

Why

Pseudo-linus oracle items shell/expansion-order and shell/brace-expansion. Brace-expanding data from a variable is also an injection-shaped bug (data turning into multiple words).

Before / After

Script Before After (= bash 5.2)
y='{a,b}'; echo $y a b {a,b}
n=3; echo {1..$n} 1 2 3 {1..3}
echo {01..10..3} 1 4 7 10 01 04 07 10
echo "{a,b}"x{1,2} {a,b}x 1 2 {a,b}x1 {a,b}x2
echo '{a,b}'{c,d} {a,b} c d {a,b}c {a,b}d
echo {a,"b c"} a "b c" a b c
echo {x}{a,b} {x} a b {x}a {x}b
echo {,a} a a
echo a{b\,c,d} ab\ ac ad ab,c ad

New spec brace-expansion-order.test.sh (7 cases, verified against bash); brace_empty_item lost its bash_diff.

Risk

Medium: lexer change for words containing {. All lib, integration (spec) and bash_comparison tests pass. Known gap, recorded in limitations: bash expands raw text, so $v{1,2} reads $v1; we keep $v and append.

Checklist

  • Tests (spec, verified against bash)
  • cargo fmt, cargo clippy -D warnings
  • lib + integration + bash_comparison tests
  • knowledge updated (parser.md, limitations.md, log.md)

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

Brace expansion now runs on the parsed word, before parameter and
command expansion, treating everything but unquoted literal text as
opaque. Expansion results no longer brace-expand, quoted and escaped
braces and commas stay literal, invalid groups keep later groups
expanding, empty items are dropped and ranges zero-pad. The lexer
treats braces as ordinary word characters.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 3ff18b0 Commit Preview URL

Branch Preview URL
Oct 07 2026, 05:23 PM

@chaliy
chaliy merged commit b1416ba into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/shell-gaps branch October 7, 2026 17:38
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.

1 participant