]> granicus.if.org Git - icinga2/commitdiff
Use CompatUtility::GetCommandLine in StatusDataWriter::DumpCommand.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 17 Dec 2013 09:20:28 +0000 (10:20 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 17 Dec 2013 09:20:28 +0000 (10:20 +0100)
Fixes #5353

components/compat/statusdatawriter.cpp
lib/icinga/compatutility.cpp

index 80e50f7d51ec0ea97be53500e259453caa5a1d01..b1947464bc7f45f8429f888fe6a62b1dcea9f51d 100644 (file)
@@ -134,24 +134,7 @@ void StatusDataWriter::DumpCommand(std::ostream& fp, const Command::Ptr& command
 
        fp << command->GetName() << "\n";
 
-       fp << "\t" "command_line\t";
-
-       Value commandLine = command->GetCommandLine();
-
-       if (commandLine.IsObjectType<Array>()) {
-               Array::Ptr args = commandLine;
-
-               ObjectLock olock(args);
-               String arg;
-               BOOST_FOREACH(arg, args) {
-                       // This is obviously incorrect for non-trivial cases.
-                       fp << " \"" << CompatUtility::EscapeString(arg) << "\"";
-               }
-       } else if (!commandLine.IsEmpty()) {
-               fp << CompatUtility::EscapeString(commandLine);
-       } else {
-               fp << "<internal>";
-       }
+       fp << "\t" "command_line" "\t" << CompatUtility::GetCommandLine(command);
 
        fp << "\n" "\t" "}" "\n"
              "\n";
index 1a394867ab50fa7a5a79940523100568db92130e..7f86b8230958e742b99da86cfe2b01d13bc394ae 100644 (file)
@@ -39,7 +39,7 @@ String CompatUtility::GetCommandLine(const Command::Ptr& command)
 {
        Value commandLine = command->GetCommandLine();
 
-       String commandline;
+       String result;
        if (commandLine.IsObjectType<Array>()) {
                Array::Ptr args = commandLine;
 
@@ -47,15 +47,15 @@ String CompatUtility::GetCommandLine(const Command::Ptr& command)
                String arg;
                BOOST_FOREACH(arg, args) {
                        // This is obviously incorrect for non-trivial cases.
-                       commandline = " \"" + EscapeString(arg) + "\"";
+                       result += " \"" + EscapeString(arg) + "\"";
                }
        } else if (!commandLine.IsEmpty()) {
-               commandline = EscapeString(Convert::ToString(commandLine));
+               result = EscapeString(Convert::ToString(commandLine));
        } else {
-               commandline = "<internal>";
+               result = "<internal>";
        }
 
-       return commandline;
+       return result;
 }
 
 /* host */