From 729933062be80d8c6c6f0b7cf79810c9cb8bb394 Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Thu, 28 Jun 2007 11:11:09 +0000 Subject: [PATCH] before merging executeAndPrintShellCommand to runProgram --- src/libutil/util.cc | 12 ++++++++++++ src/libutil/util.hh | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 0dfef7763..39476c90a 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1069,6 +1069,18 @@ string trim(const string & s) { */ +string runProgram_AndPrintOutput(Path program, bool searchPath, const Strings & args, const string outputPrefix) +{ + string program_output = runProgram(program, true, args); + + //Add the prefix on every line + //TODO + + //Remove the trailing \n + size_t found = program_output.find_last_of("\n"); + printMsg(lvlError, format("%1%") % program_output.substr(0,found)); +} + void executeAndPrintShellCommand(const string & command, const string & commandName, const bool & captureOutput) { /////////////////////// diff --git a/src/libutil/util.hh b/src/libutil/util.hh index bf70230e9..1aa627942 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -295,6 +295,9 @@ string trim(const string & s); //excecute a shell command void executeAndPrintShellCommand(const string & command, const string & commandName, const bool & captureOutput); +// +string runProgram_AndPrintOutput(Path program, bool searchPath, const Strings & args, const string outputPrefix); + //Convert time_t to a string string time_t2string(const time_t & t);