mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
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:
parent
b2eed01051
commit
67c5bb5985
1 changed files with 1 additions and 2 deletions
|
@ -383,9 +383,8 @@ class Commands:
|
|||
"Run a shell command and optionally add the output to the chat"
|
||||
combined_output = None
|
||||
try:
|
||||
parsed_args = shlex.split(args)
|
||||
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
|
||||
except Exception as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue