Skip to content

fix: append newline to shell wrapper to protect here-doc terminators - #15

Open
CodeOptimist wants to merge 1 commit into
Sentdex:masterfrom
CodeOptimist:master
Open

fix: append newline to shell wrapper to protect here-doc terminators#15
CodeOptimist wants to merge 1 commit into
Sentdex:masterfrom
CodeOptimist:master

Conversation

@CodeOptimist

Copy link
Copy Markdown

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.

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.
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.

1 participant