From eb43a1fb43538922ca884f516cf9b43498d32f84 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 21 Aug 2024 13:23:01 -0700 Subject: [PATCH] fix: Handle empty and commented shell commands in EditBlockCoder --- aider/coders/editblock_coder.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/aider/coders/editblock_coder.py b/aider/coders/editblock_coder.py index fb41901c6..632cd1250 100644 --- a/aider/coders/editblock_coder.py +++ b/aider/coders/editblock_coder.py @@ -42,20 +42,30 @@ class EditBlockCoder(Coder): failed = [] passed = [] + dump(edits) for edit in edits: + dump(edit) if edit[0] is None: edit = edit[1] # This is a shell command - commands = edit.strip().split("\n") + commands = edit.strip().splitlines() if self.io.confirm_ask("Run shell command(s)?", subject="\n".join(commands)): - self.io.tool_output() for command in commands: + command = command.strip() + if not command: + continue + if command.startswith('#'): + continue + + self.io.tool_output() + self.io.tool_output(f"Running {command}") try: # Add the command to input history self.io.add_to_input_history(f"/run {command.strip()}") self.run_interactive_subprocess(command.split()) except Exception as e: self.io.tool_error(f"Error running command '{command}': {str(e)}") + continue else: path, original, updated = edit full_path = self.abs_root_path(path)