fix(interpreter): write heredoc content when redirected to file#370
Merged
fix(interpreter): write heredoc content when redirected to file#370
Conversation
Closes #345 The parser's heredoc handling broke out of the simple-command loop immediately after consuming the heredoc body, which discarded any tokens on the same line after the delimiter (e.g. `> file` in `cat <<EOF > file`). The lexer also skipped the rest-of-line text. Fix: the lexer now saves the rest-of-line text after the heredoc delimiter into `heredoc_rest_of_line`. The parser reads this field, creates a sub-parser to extract additional redirects, and adds them to the command's redirect list before breaking. https://claude.ai/code/session_018RLVEEcJBFYsxQKT5wYyNu
…parsing The sub-parser approach using parse_simple_command() returned None for redirect-only input (e.g. ` > file` with no command word), silently dropping the output redirect. Parse redirect tokens directly from the rest-of-line instead. Also change heredoc_redirect_after_multiline test to use /tmp/app/ instead of /etc/app/ which requires root in CI. https://claude.ai/code/session_01QbjrsMFJbHy5XfHCzA6TjM
e619123 to
e8dc217
Compare
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
cat <<EOF > file) which previously wrote to stdout instead of the fileCloses #345
Test plan
heredoc_redirect_after,heredoc_redirect_after_with_vars,heredoc_redirect_after_multilinetest_read_heredoc_with_redirectheredoc_to_filetest (cat > file <<EOFsyntax) still passescargo fmt --checkcleancargo clippy -- -D warningsclean