Skip to content

Commit e63a703

Browse files
laanwjhebasto
authored andcommitted
subprocess: 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. Github-Pull: arun11299/cpp-subprocess#119 Rebased-From: 777cfa77d1f84bb08b3e445d5f7fc6c87282223b
1 parent af65fd1 commit e63a703

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/util/subprocess.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,11 +1124,16 @@ inline void Popen::execute_process() noexcept(false)
11241124
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
11251125
std::wstring argument;
11261126
std::wstring command_line;
1127+
bool first_arg = true;
11271128

11281129
for (auto arg : this->vargs_) {
1130+
if (!first_arg) {
1131+
command_line += L" ";
1132+
} else {
1133+
first_arg = false;
1134+
}
11291135
argument = converter.from_bytes(arg);
11301136
util::quote_argument(argument, command_line, false);
1131-
command_line += L" ";
11321137
}
11331138

11341139
// CreateProcessW can modify szCmdLine so we allocate needed memory

0 commit comments

Comments
 (0)