From 730e763718cffa7abb064ffe7a44ca21d96a1d09 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Thu, 30 Apr 2026 03:50:06 +0200 Subject: [PATCH] ShellQuote: use double quotes on Windows 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 ''"). Co-Authored-By: Claude Sonnet 4.6 --- implementations/Crafter.Build-External.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/implementations/Crafter.Build-External.cpp b/implementations/Crafter.Build-External.cpp index d9dbba5..dbb0e6c 100644 --- a/implementations/Crafter.Build-External.cpp +++ b/implementations/Crafter.Build-External.cpp @@ -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 options) {