diff --git a/src/render.cpp b/src/render.cpp index 845c17e..9912dc5 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "log.h" #include "process_.h" @@ -108,8 +109,23 @@ namespace anm2ed command += " 2>&1"; #if _WIN32 - command = "powershell -Command \"& { " + command + " | Tee-Object -FilePath " + string::quote(loggerPathString) + - " -Append }\""; + auto escape_double_quotes_for_cmd = [](const std::string& input) + { + std::string escaped{}; + escaped.reserve(input.size() * 2); + for (char character : input) + { + if (character == '"') + escaped += "\"\""; + else + escaped += character; + } + return escaped; + }; + + auto powershellScript = + std::string("& { & ") + command + " | Tee-Object -FilePath " + string::quote(loggerPathString) + " -Append }"; + command = "powershell -Command \"" + escape_double_quotes_for_cmd(powershellScript) + "\""; #else command += " | tee -a " + string::quote(loggerPathString); #endif