cmOutputConverter: add a static version of EscapeForShell

This commit is contained in:
Ben Boeckel
2023-05-16 11:27:06 -04:00
parent bafb6e999d
commit 81d45dabc4
2 changed files with 11 additions and 5 deletions

View File

@@ -243,11 +243,6 @@ std::string cmOutputConverter::EscapeForShell(cm::string_view str,
bool unescapeNinjaConfiguration,
bool forResponse) const
{
// Do not escape shell operators.
if (cmOutputConverterIsShellOperator(str)) {
return std::string(str);
}
// Compute the flags for the target shell environment.
int flags = 0;
if (this->GetState()->UseWindowsVSIDE()) {
@@ -283,6 +278,16 @@ std::string cmOutputConverter::EscapeForShell(cm::string_view str,
flags |= Shell_Flag_IsUnix;
}
return cmOutputConverter::EscapeForShell(str, flags);
}
std::string cmOutputConverter::EscapeForShell(cm::string_view str, int flags)
{
// Do not escape shell operators.
if (cmOutputConverterIsShellOperator(str)) {
return std::string(str);
}
return Shell_GetArgument(str, flags);
}

View File

@@ -107,6 +107,7 @@ public:
bool forEcho = false, bool useWatcomQuote = false,
bool unescapeNinjaConfiguration = false,
bool forResponse = false) const;
static std::string EscapeForShell(cm::string_view str, int flags);
enum class WrapQuotes
{