mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 12:45:00 +00:00
fix: Refactor run_interactive_command
function to use UTF-8 encoding
This commit is contained in:
parent
90d3b8fab6
commit
3bd4af23da
1 changed files with 1 additions and 31 deletions
|
@ -30,37 +30,7 @@ def run_interactive_command(command):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Spawn the command
|
# Spawn the command
|
||||||
child = pexpect.spawn(command, encoding=None)
|
child = pexpect.spawn(command, encoding="utf-8")
|
||||||
|
|
||||||
# Transfer control to the user, capturing output
|
|
||||||
child.interact(output_filter=output_callback)
|
|
||||||
|
|
||||||
# Wait for the command to finish and get the exit status
|
|
||||||
child.close()
|
|
||||||
return child.exitstatus, output.getvalue().decode("utf-8", errors="replace")
|
|
||||||
|
|
||||||
except pexpect.ExceptionPexpect as e:
|
|
||||||
error_msg = f"Error running command: {e}"
|
|
||||||
print(error_msg, file=sys.stderr)
|
|
||||||
return 1, error_msg
|
|
||||||
|
|
||||||
|
|
||||||
def run_interactive_command(command):
|
|
||||||
"""
|
|
||||||
Run a shell command interactively using pexpect, capturing all output.
|
|
||||||
|
|
||||||
:param command: The command to run as a string.
|
|
||||||
:return: A tuple containing (exit_status, output)
|
|
||||||
"""
|
|
||||||
output = BytesIO()
|
|
||||||
|
|
||||||
def output_callback(b):
|
|
||||||
output.write(b)
|
|
||||||
return b
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Spawn the command
|
|
||||||
child = pexpect.spawn(command, encoding=None)
|
|
||||||
|
|
||||||
# Transfer control to the user, capturing output
|
# Transfer control to the user, capturing output
|
||||||
child.interact(output_filter=output_callback)
|
child.interact(output_filter=output_callback)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue