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);