Skip to content

fix(parser): preserve double quotes inside $() in double-quoted strings#826

Merged
chaliy merged 1 commit intomainfrom
fix/issue-803-single-quote-in-cmdsub
Mar 26, 2026
Merged

fix(parser): preserve double quotes inside $() in double-quoted strings#826
chaliy merged 1 commit intomainfrom
fix/issue-803-single-quote-in-cmdsub

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 26, 2026

Summary

  • Fix read_word() inline double-quote handler to properly track $() command substitutions
  • When $( is encountered inside a double-quoted word segment, delegate to read_command_subst_into() which handles nested quotes (single quotes, double quotes, escapes)
  • Previously, a " inside a single-quoted string within $() was misinterpreted as the closing delimiter of the outer double-quoted segment

Test plan

  • cmdsub_preserves_double_quotes_in_single_quotesx="$(echo '{"a":1}')" preserves "
  • cmdsub_preserves_double_quotes_simpley="$(echo 'say "hello" please')" preserves "
  • cmdsub_without_outer_quotes_works — baseline without outer quotes still works
  • Full test suite passes

Closes #803

Closes #803 — single-quoted strings inside command substitutions within
double-quoted word segments now preserve embedded double quotes.

Root cause: the inline double-quote handler in read_word() didn't track
$(...) command substitutions, so a " inside a single-quoted string within
$() was treated as the closing delimiter of the outer double-quoted segment.

Fix: when encountering $( inside an inline double-quoted segment, delegate
to read_command_subst_into() which properly handles nested quotes.
@chaliy chaliy merged commit b357e37 into main Mar 26, 2026
18 of 23 checks passed
@chaliy chaliy deleted the fix/issue-803-single-quote-in-cmdsub branch March 26, 2026 13:34
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.

bug: single-quoted strings inside $(...) lose embedded double quotes

1 participant