fix(parser): prevent word-splitting inside quoted strings during array assignment#1082
Merged
fix(parser): prevent word-splitting inside quoted strings during array assignment#1082
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QuotedWordtokens incollect_array_elements()not being markedquoted=true, causing IFS word-splitting on double-quoted variable expansions likearr=(-a "test ${X} done")split_array_elements()for the single-token array literal code pathTest plan
quoted_expansion_no_word_split_in_array— verifies exact bug from Array assignment word-splits quoted strings containing variable expansion #1071quoted_single_quote_no_word_split_in_array— single-quoted elements preservedquoted_mixed_elements_in_array— mixed quoted/unquoted/variable expansionbash_comparison_testspass (differential test against real bash)cargo run --bin bashkit -- -c '...'produces correct outputcargo clippyclean,cargo fmtcleanCloses #1071