Skip to content

Commit 777cfa7

Browse files
authored
windows: Don't add an extra whitespace at end of Windows command line (arun11299#119)
The windows code adds an unnecessary extra space to the command line. This can cause subtle issues, so avoid it.
1 parent f6232a7 commit 777cfa7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cpp-subprocess/subprocess.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,11 +1541,16 @@ inline void Popen::execute_process() noexcept(false)
15411541
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
15421542
std::wstring argument;
15431543
std::wstring command_line;
1544+
bool first_arg = true;
15441545

15451546
for (auto arg : this->vargs_) {
1547+
if (!first_arg) {
1548+
command_line += L" ";
1549+
} else {
1550+
first_arg = false;
1551+
}
15461552
argument = converter.from_bytes(arg);
15471553
util::quote_argument(argument, command_line, false);
1548-
command_line += L" ";
15491554
}
15501555

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

0 commit comments

Comments
 (0)