Skip to content

fix(interpreter): apply word splitting for unquoted expansions in array assignments#1025

Merged
chaliy merged 1 commit intomainfrom
fix/issue-969-array-word-splitting
Apr 2, 2026
Merged

fix(interpreter): apply word splitting for unquoted expansions in array assignments#1025
chaliy merged 1 commit intomainfrom
fix/issue-969-array-word-splitting

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • arr=($x) now correctly word-splits unquoted variable expansions into multiple elements
  • Quoted words (e.g., arr=("a b")) are kept as single elements
  • Uses existing expand_word_to_fields for proper IFS-based splitting

Why

x="hello world"; arr=($x) produced a single-element array instead of splitting into two elements. This is a standard bash pattern for creating arrays from whitespace-separated strings.

Tests

  • Added spec tests: unquoted_expansion_word_split_in_array, unquoted_expansion_custom_ifs_in_array
  • 100% bash comparison match (1701/1701)

Closes #969

…ay assignments

arr=($x) where x="hello world" now correctly splits into multiple
array elements. Unquoted variable expansions in array literals now
go through expand_word_to_fields which applies IFS word splitting,
while quoted words are kept as single elements.

Closes #969
@chaliy chaliy merged commit 79bfe6b into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-969-array-word-splitting branch April 2, 2026 22:17
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.

Unquoted variable expansion in array assignment does not apply word splitting

1 participant