From 0814d0a6559ed3634dafb372f34491407a27c5e8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 15 Nov 2013 13:31:00 -0500 Subject: cmSystemTools: Add PrintSingleCommand method Add a method to print a command line for human reference by simply double-quoting every argument. --- Source/cmSystemTools.cxx | 17 +++++++++++++++++ Source/cmSystemTools.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 8a0d8dc..b3dbd05 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -795,6 +795,23 @@ bool cmSystemTools::RunSingleCommand( dir, outputflag, timeout); } +std::string +cmSystemTools::PrintSingleCommand(std::vector const& command) +{ + std::string commandStr; + const char* sep = ""; + for(std::vector::const_iterator i = command.begin(); + i != command.end(); ++i) + { + commandStr += sep; + commandStr += "\""; + commandStr += *i; + commandStr += "\""; + sep = " "; + } + return commandStr; +} + bool cmSystemTools::DoesFileExistWithExtensions( const char* name, const std::vector& headerExts) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 95c7029..4e854c8 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -239,6 +239,8 @@ public: OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); + static std::string PrintSingleCommand(std::vector const&); + /** * Parse arguments out of a single string command */ -- cgit v0.12