Skip to content

Comments

fix(bash): nested double quotes inside $() in double-quoted strings#246

Merged
chaliy merged 1 commit intomainfrom
claude/bashkit-bash-compatibility-BsDKD
Feb 24, 2026
Merged

fix(bash): nested double quotes inside $() in double-quoted strings#246
chaliy merged 1 commit intomainfrom
claude/bashkit-bash-compatibility-BsDKD

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 24, 2026

Summary

  • Fix lexer to handle nested double quotes inside $() command substitutions within double-quoted strings
  • echo "$(echo "$x")" now correctly expands instead of prematurely closing the outer quotes
  • Add read_command_subst_into() method that tracks paren depth and handles nested quotes recursively

Test plan

  • 8 new spec tests covering nested quotes, variable expansion, deeply nested $(), single quotes, empty strings, multiple substitutions, and escaped characters
  • All 1194 spec tests pass (1189 pass, 5 skip)
  • cargo clippy and cargo fmt clean

The lexer's read_double_quoted_string treated inner `"` inside `$()`
as the closing quote, breaking patterns like `echo "$(echo "$x")"`.

Add read_command_subst_into() that tracks paren depth and handles
nested double/single quotes recursively, supporting arbitrary nesting.

Add 8 spec tests for nested quote scenarios.
@chaliy chaliy merged commit 30377ee into main Feb 24, 2026
16 checks passed
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.

2 participants