mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-07 21:24:59 +00:00
feat: respect user's shell environment in subprocess execution
This commit is contained in:
parent
b8ce472cb6
commit
e3b7b80280
1 changed files with 15 additions and 0 deletions
|
@ -26,12 +26,27 @@ def run_cmd_subprocess(command, verbose=False):
|
|||
if verbose:
|
||||
print("Using run_cmd_subprocess:", command)
|
||||
try:
|
||||
# Determine the appropriate shell
|
||||
if platform.system() == "Windows":
|
||||
# Use PowerShell if it's the parent process
|
||||
if "powershell" in os.environ.get("PSModulePath", "").lower():
|
||||
shell = "powershell"
|
||||
command = f"powershell -Command {command}"
|
||||
else:
|
||||
shell = "cmd"
|
||||
else:
|
||||
shell = os.environ.get("SHELL", "/bin/sh")
|
||||
|
||||
if verbose:
|
||||
print(f"Using shell: {shell}")
|
||||
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
shell=True,
|
||||
executable=shell,
|
||||
encoding=sys.stdout.encoding,
|
||||
errors="replace",
|
||||
bufsize=1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue