From 5b1a839d63d5fd9178c009d28e85fd468d5b3824 Mon Sep 17 00:00:00 2001 From: GuDaStudio Date: Sun, 9 Nov 2025 14:38:16 +0800 Subject: [PATCH] =?UTF-8?q?v0.4.1=EF=BC=9A=E4=BF=AE=E5=A4=8DWindows?= =?UTF-8?q?=E4=B8=8B=E6=97=A0=E9=99=90=E6=8C=82=E8=B5=B7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/codexmcp/server.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/codexmcp/server.py b/src/codexmcp/server.py index 562e320..290b7af 100644 --- a/src/codexmcp/server.py +++ b/src/codexmcp/server.py @@ -33,12 +33,18 @@ def run_shell_command(cmd: list[str]) -> Generator[str, None, None]: Yields: Output lines from the command """ - # On Windows, wrap command with cmd.exe to execute .cmd batch files - popen_cmd = ["cmd", "/c", *cmd] if os.name == "nt" else cmd + # On Windows, codex is exposed via a *.cmd shim. Use cmd.exe with /s so + # user prompts containing quotes/newlines aren't reinterpreted as shell syntax. + if os.name == "nt": + quoted_cmd = subprocess.list2cmdline(cmd) + popen_cmd = ["cmd", "/d", "/s", "/c", quoted_cmd] + else: + popen_cmd = cmd process = subprocess.Popen( popen_cmd, shell=False, # Safer: no shell injection + stdin=subprocess.DEVNULL, # Prevent process from waiting for input stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True,