aider: Remove the use of shlex.split(args) in cmd_run method.

# Aider chat conversation:

USER: what does shlex.split(args) do?

ASSISTANT: The `shlex.split(args)` function is a method in Python's `shlex` module. It splits the string `args` into a list of substrings, using shell-like syntax. This means it handles quotes and backslashes like a Unix shell would.

For example, if `args` is a string like `"command -option 'argument with spaces'"`, `shlex.split(args)` would return the list `['command', '-option', 'argument with spaces']`.

This is useful when you want to pass a command line command as a string to a function like `subprocess.run()`, which expects a list of arguments.

USER: remove the use of shlex in cmd_run

ASSISTANT: To remove the use of `shlex.split(args)` in the `cmd_run` method, we need to modify the `aider/commands.py` file. Here's the change:

<source>python
aider/commands.py
<<<<<<< HEAD
            parsed_args = shlex.split(args)
            result = subprocess.run(
                parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True
            )
=======
            result = subprocess.run(
                args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True
            )
>>>>>>> updated
</source>
This commit is contained in:
Alexander Kjeldaas 2023-10-01 19:51:38 +02:00
parent b2eed01051
commit 67c5bb5985

View file

@ -383,9 +383,8 @@ class Commands:
"Run a shell command and optionally add the output to the chat" "Run a shell command and optionally add the output to the chat"
combined_output = None combined_output = None
try: try:
parsed_args = shlex.split(args)
result = subprocess.run( result = subprocess.run(
parsed_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True
) )
combined_output = result.stdout combined_output = result.stdout
except Exception as e: except Exception as e: