fix(win): use PowerShell instead of cmd.exe

This commit is contained in:
zhayujie
2026-04-08 16:50:45 +08:00
parent 89251e603f
commit 424557fedb

View File

@@ -108,12 +108,13 @@ SAFETY:
if self._IS_WIN: if self._IS_WIN:
env["PYTHONIOENCODING"] = "utf-8" env["PYTHONIOENCODING"] = "utf-8"
# Use PowerShell so that LLM-generated commands can use wrapped = (
# Select-String, Select-Object, curl (Invoke-WebRequest alias), "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; "
# etc. instead of Unix-only head/grep/tail. f"{command}; exit $LASTEXITCODE"
)
result = subprocess.run( result = subprocess.run(
["powershell.exe", "-NoProfile", "-NonInteractive", ["powershell.exe", "-NoProfile", "-NonInteractive",
"-ExecutionPolicy", "Bypass", "-Command", command], "-ExecutionPolicy", "Bypass", "-Command", wrapped],
cwd=self.cwd, cwd=self.cwd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,