Commit 3cca974
fix(interpreter): write heredoc content when redirected to file (#370)
## Summary
- Fix heredoc redirect to file (`cat <<EOF > file`) which previously
wrote to stdout instead of the file
- Lexer now captures rest-of-line text after heredoc delimiter instead
of discarding it
- Parser creates a sub-parser to extract additional redirects from the
rest-of-line
Closes #345
## Test plan
- [x] Added 3 new spec tests: `heredoc_redirect_after`,
`heredoc_redirect_after_with_vars`, `heredoc_redirect_after_multiline`
- [x] Added lexer unit test `test_read_heredoc_with_redirect`
- [x] All 1308 bash spec tests pass (100% pass rate)
- [x] Existing `heredoc_to_file` test (`cat > file <<EOF` syntax) still
passes
- [x] `cargo fmt --check` clean
- [x] `cargo clippy -- -D warnings` clean
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6994214 commit 3cca974
File tree
3 files changed
+114
-6
lines changed- crates/bashkit
- src/parser
- tests/spec_cases/bash
3 files changed
+114
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
1208 | 1212 | | |
1209 | 1213 | | |
1210 | 1214 | | |
1211 | | - | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
1212 | 1219 | | |
1213 | 1220 | | |
1214 | 1221 | | |
1215 | 1222 | | |
1216 | 1223 | | |
| 1224 | + | |
1217 | 1225 | | |
1218 | 1226 | | |
1219 | 1227 | | |
| |||
1362 | 1370 | | |
1363 | 1371 | | |
1364 | 1372 | | |
| 1373 | + | |
1365 | 1374 | | |
1366 | 1375 | | |
1367 | 1376 | | |
1368 | 1377 | | |
1369 | 1378 | | |
1370 | 1379 | | |
1371 | 1380 | | |
| 1381 | + | |
1372 | 1382 | | |
1373 | 1383 | | |
1374 | 1384 | | |
| |||
1384 | 1394 | | |
1385 | 1395 | | |
1386 | 1396 | | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
1387 | 1409 | | |
1388 | 1410 | | |
1389 | 1411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1768 | 1768 | | |
1769 | 1769 | | |
1770 | 1770 | | |
1771 | | - | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
1772 | 1774 | | |
| 1775 | + | |
1773 | 1776 | | |
1774 | 1777 | | |
1775 | 1778 | | |
1776 | 1779 | | |
1777 | 1780 | | |
1778 | 1781 | | |
1779 | | - | |
| 1782 | + | |
1780 | 1783 | | |
1781 | 1784 | | |
1782 | 1785 | | |
| |||
1787 | 1790 | | |
1788 | 1791 | | |
1789 | 1792 | | |
1790 | | - | |
1791 | | - | |
1792 | | - | |
1793 | 1793 | | |
1794 | 1794 | | |
1795 | 1795 | | |
| |||
1810 | 1810 | | |
1811 | 1811 | | |
1812 | 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 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
1813 | 1861 | | |
1814 | 1862 | | |
1815 | 1863 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
86 | 124 | | |
87 | 125 | | |
88 | 126 | | |
| |||
0 commit comments