ShellQuote: use double quotes on Windows
All checks were successful
CI / build-test-release (push) Successful in 14m41s
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:
parent
c6018581c1
commit
730e763718
1 changed files with 13 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue