Skip to content

fix(lexer): a case pattern's ) inside a quoted substitution - #193

Closed
LESdylan wants to merge 1 commit into
fix/nested-cmdsub-quotefrom
fix/lexer-cmdsub-case
Closed

LESdylan wants to merge 1 commit into
fix/nested-cmdsub-quotefrom
fix/lexer-cmdsub-case

Conversation

@LESdylan

@LESdylan LESdylan commented Nov 4, 2026

Copy link
Copy Markdown
Member

Closes #191

Stacked on the nested-quote fix: a case nested in a case needs both halves. This targets that branch so the diff stays one concern, and GitHub moves it to develop when the first one merges.

Problem

advance_cmdsub counted parens, so in x="$(case a in a) echo "q'r";; esac)" the pattern's ) closed the substitution and a valid command was a syntax error.

Fix

advance_cmdsub delegates to span_skip, which handles this through casescan (#95). The lexer and the expander no longer hold two walkers that can disagree.

Tests

  • Five cases join tests/issue95_case_cmdsub.
  • make test against the pinned bash 5.3.9: 5386/5386.
  • make all debug build (-Werror): no warnings.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d99b37a-7b9c-481a-96a5-2abefaf1aa9f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

advance_cmdsub counted parens, so the `)` of a case pattern closed a $(...) that
sits inside a double-quoted word. The scan went on with the word's quote out of
step, and a valid command was refused:

    x="$(case a in a) echo "q'r";; esac)"   # bash: q'r
                                            # hellish: syntax error

span_skip already walks these spans through casescan, the automaton #95 added for
the same `)`, so advance_cmdsub delegates to it and a second walker goes.

Stacked on fix/nested-cmdsub-quote: a case nested in a case needs that half too.
Five cases join tests/issue95_case_cmdsub.

Closes #191

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LESdylan
LESdylan force-pushed the fix/nested-cmdsub-quote branch from f51018e to 28203eb Compare November 4, 2026 14:45
@LESdylan
LESdylan force-pushed the fix/lexer-cmdsub-case branch from 111fcf5 to acaa05f Compare November 4, 2026 14:45
@LESdylan

LESdylan commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

Landed on develop by fast-forward: this PR's head acaa05f is now develop. GitHub cannot mark it merged because its base is fix/nested-cmdsub-quote, so it is closed by hand. CI on acaa05f before landing: 34 success, 3 skipped.

@LESdylan LESdylan closed this Nov 4, 2026
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