From 81d45dabc4534f15b8c61935060cd4d10f258f15 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 16 May 2023 11:27:06 -0400 Subject: cmOutputConverter: add a `static` version of `EscapeForShell` --- Source/cmOutputConverter.cxx | 15 ++++++++++----- Source/cmOutputConverter.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 53cb21e..02981ae 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -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); } diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 625d897..0ee7afb 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -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 { -- cgit v0.12