From 34fb3871a73689714ca2794e2c896c9fb18bc311 Mon Sep 17 00:00:00 2001 From: laanwj <126646+laanwj@users.noreply.github.com> Date: Tue, 20 May 2025 09:22:44 +0200 Subject: [PATCH] windows: Don't add an extra whitespace at end of Windows command line The windows code adds an unnecessary extra space to the command line. This can cause subtle issues, so avoid it. --- cpp-subprocess/subprocess.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cpp-subprocess/subprocess.hpp b/cpp-subprocess/subprocess.hpp index 1b35574..216540a 100644 --- a/cpp-subprocess/subprocess.hpp +++ b/cpp-subprocess/subprocess.hpp @@ -1541,11 +1541,16 @@ inline void Popen::execute_process() noexcept(false) std::wstring_convert> converter; std::wstring argument; std::wstring command_line; + bool first_arg = true; for (auto arg : this->vargs_) { + if (!first_arg) { + command_line += L" "; + } else { + first_arg = false; + } argument = converter.from_bytes(arg); util::quote_argument(argument, command_line, false); - command_line += L" "; } // CreateProcessW can modify szCmdLine so we allocate needed memory