Commit 834adf5
authored
fix(parser): prevent word-splitting inside quoted strings during array assignment (#1082)
## 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
- [x] Spec test `quoted_expansion_no_word_split_in_array` — verifies
exact bug from #1071
- [x] Spec test `quoted_single_quote_no_word_split_in_array` —
single-quoted elements preserved
- [x] Spec test `quoted_mixed_elements_in_array` — mixed
quoted/unquoted/variable expansion
- [x] All existing array spec tests still pass
- [x] `bash_comparison_tests` pass (differential test against real bash)
- [x] Smoke test via `cargo run --bin bashkit -- -c '...'` produces
correct output
- [x] `cargo clippy` clean, `cargo fmt` clean
Closes #10711 parent 6ac3af0 commit 834adf5
File tree
3 files changed
+105
-4
lines changed- crates/bashkit
- src/parser
- tests/spec_cases/bash
- specs
3 files changed
+105
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1792 | 1792 | | |
1793 | 1793 | | |
1794 | 1794 | | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
1795 | 1848 | | |
1796 | 1849 | | |
1797 | 1850 | | |
| |||
1879 | 1932 | | |
1880 | 1933 | | |
1881 | 1934 | | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
1882 | 1939 | | |
1883 | 1940 | | |
1884 | 1941 | | |
| |||
1906 | 1963 | | |
1907 | 1964 | | |
1908 | 1965 | | |
1909 | | - | |
1910 | | - | |
1911 | | - | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
1912 | 1977 | | |
1913 | 1978 | | |
1914 | 1979 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
239 | 275 | | |
240 | 276 | | |
241 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
0 commit comments