Skip to content

fix(parser): prevent word-splitting inside quoted strings during array assignment#1082

Merged
chaliy merged 2 commits intomainfrom
claude/fix-array-word-split-JxlCg
Apr 6, 2026
Merged

fix(parser): prevent word-splitting inside quoted strings during array assignment#1082
chaliy merged 2 commits intomainfrom
claude/fix-array-word-split-JxlCg

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 6, 2026

Summary

  • Fix QuotedWord tokens in collect_array_elements() not being marked quoted=true, causing IFS word-splitting on double-quoted variable expansions like arr=(-a "test ${X} done")
  • Add quote-aware split_array_elements() for the single-token array literal code path
  • Add 3 spec tests: quoted expansion, single-quoted elements, mixed quoted/unquoted elements

Test plan

  • Spec test quoted_expansion_no_word_split_in_array — verifies exact bug from Array assignment word-splits quoted strings containing variable expansion #1071
  • Spec test quoted_single_quote_no_word_split_in_array — single-quoted elements preserved
  • Spec test quoted_mixed_elements_in_array — mixed quoted/unquoted/variable expansion
  • All existing array spec tests still pass
  • bash_comparison_tests pass (differential test against real bash)
  • Smoke test via cargo run --bin bashkit -- -c '...' produces correct output
  • cargo clippy clean, cargo fmt clean

Closes #1071

chaliy added 2 commits April 6, 2026 00:24
…y assignment

QuotedWord tokens in collect_array_elements() were not marked with
quoted=true, causing the interpreter to apply IFS word-splitting to
double-quoted variable expansions like arr=(-a "test ${X} done").

Also adds a quote-aware splitter for the single-token array literal
code path (arr=(a b c) packed into one token).

Closes #1071
Add tests for single-quoted and mixed quoted/unquoted array elements.
Update spec test count in implementation status.
@chaliy chaliy merged commit 834adf5 into main Apr 6, 2026
27 checks passed
@chaliy chaliy deleted the claude/fix-array-word-split-JxlCg branch April 6, 2026 00:41
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.

Array assignment word-splits quoted strings containing variable expansion

1 participant