Skip to content

fix(parser): case inside $( ) and [[ == [[:class:]] ]] patterns - #2578

Merged
chaliy merged 1 commit into
mainfrom
claude/case-in-cmdsub
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/case-in-cmdsub

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

What changed

  • case works inside $( ), backticks and "$( )": the $( ) end scanner follows case syntax (subject, in, patterns, bodies, ;;/;&/;;&), so a pattern's ) no longer closes the substitution. Nested and multi-line forms work; echo case) still closes normally.
  • [[ $z == [[:digit:]]* ]] and [[ a1 == [[:alpha:]][[:digit:]] ]] work: [[ is the keyword only before a word break, otherwise it starts a bracket-expression word.
  • Compound commands (case, if, { }) inside a command substitution no longer leak their output to the streaming output callback (the CLI printed it twice).

Why

Items from the pseudo-linus oracle gap list (case in $( ), POSIX class patterns in [[ ]]).

Before / After

Script Before After (= bash)
echo "$(case b in a) echo A;; b) echo B;; esac)" substitution closed at the first pattern ), parse error B
z=5a; [[ $z == [[:digit:]]* ]] && echo digit no output digit
case 5 in [[:digit:]]) echo d;; esac no output d

New spec case-in-cmdsub.test.sh (7 cases, all verified against bash 5.2), scanner unit tests, and a streaming test command_substitution_output_is_not_streamed (failed before the fix).

Risk

Low. The scanner only changes depth tracking for unquoted case keywords in command position; all spec, integration and bash comparison tests pass.

Checklist

  • Failing tests first
  • cargo fmt, cargo clippy -D warnings
  • lib + integration + bash_comparison tests
  • knowledge updated (parser.md, log.md)

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

The $( ) end scanner follows case patterns, so a pattern `)` no longer
closes the substitution. `[[` is a keyword only before a word break, so
`[[:digit:]]*` lexes as a pattern word. Command substitutions no longer
stream compound-command output to the output callback.

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 a8fd20f Commit Preview URL

Branch Preview URL
Oct 07 2026, 05:20 PM

@chaliy
chaliy merged commit 2214172 into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/case-in-cmdsub branch October 7, 2026 17:37
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