From 4dffd5b55ce9b78c49b8c96eb314008d51c7e37c Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:11:25 +0100 Subject: [PATCH] Do not escape double quotes for command line arguments on Windows This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`. --- subprocess.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprocess.hpp b/subprocess.hpp index 826cd9c..3975eb6 100755 --- a/subprocess.hpp +++ b/subprocess.hpp @@ -193,7 +193,7 @@ namespace util // if (force == false && argument.empty() == false && - argument.find_first_of(L" \t\n\v\"") == argument.npos) { + argument.find_first_of(L" \t\n\v") == argument.npos) { command_line.append(argument); } else {