ShellQuote: use double quotes on Windows
All checks were successful
CI / build-test-release (push) Successful in 14m41s

cmd.exe treats single quotes as literal characters, so the existing
single-quote wrapping broke git/cmake invocations on a Windows host
("could not create leading directories of '<path>'").

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-04-30 03:50:06 +02:00
commit 730e763718

View file

@ -37,6 +37,18 @@ std::string DeriveName(const GitSource& source) {
}
std::string ShellQuote(std::string_view s) {
// Windows cmd treats single quotes as literal characters — only double
// quotes work. Paths don't contain " in practice, so a simple wrap
// suffices; backslashes inside the path stay backslashes.
#ifdef _WIN32
std::string out = "\"";
for (char c : s) {
if (c == '"') out += "\\\"";
else out += c;
}
out += "\"";
return out;
#else
std::string out = "'";
for (char c : s) {
if (c == '\'') out += "'\\''";
@ -44,6 +56,7 @@ std::string ShellQuote(std::string_view s) {
}
out += "'";
return out;
#endif
}
std::string JoinOptions(std::span<const std::string> options) {