fix: append newline to shell wrapper to protect here-doc terminators - #15
Open
CodeOptimist wants to merge 1 commit into
Open
fix: append newline to shell wrapper to protect here-doc terminators#15CodeOptimist wants to merge 1 commit into
CodeOptimist wants to merge 1 commit into
Conversation
When the agent generates a bash command that ends exactly on a here-document delimiter (like `EOF`) or an inline shell comment without a trailing newline, the agent's subshell wrapper `({command});` inadvertently appends the closing `);` directly to that last line.
This causes the shell parser to absorb the closing parenthesis into the here-doc body or comment, leaving the subshell unclosed and resulting in a `Syntax error: end of file unexpected (expecting ")")` crash.
By inserting a guaranteed newline immediately after the interpolated command `({command}\n);`, we isolate the wrapper's syntax from the LLM's raw output, ensuring here-docs and comments terminate cleanly.
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.
Intro (human)
Just thought I'd say a quick hello; this isn't an autonomous PR. 😆👋
Commit description (LLM)
When the agent generates a bash command that ends exactly on a here-document delimiter (like
EOF) or an inline shell comment without a trailing newline, the agent's subshell wrapper({command});inadvertently appends the closing);directly to that last line.This causes the shell parser to absorb the closing parenthesis into the here-doc body or comment, leaving the subshell unclosed and resulting in a
Syntax error: end of file unexpected (expecting ")")crash.By inserting a guaranteed newline immediately after the interpolated command
({command}\n);, we isolate the wrapper's syntax from the LLM's raw output, ensuring here-docs and comments terminate cleanly.