diff --git a/lib/cli/consolecommand.cpp b/lib/cli/consolecommand.cpp index 7ea0054b4..690fcc14e 100644 --- a/lib/cli/consolecommand.cpp +++ b/lib/cli/consolecommand.cpp @@ -35,7 +35,7 @@ using namespace icinga; namespace po = boost::program_options; -static ScriptFrame l_ScriptFrame; +static ScriptFrame *l_ScriptFrame; REGISTER_CLICOMMAND("console", ConsoleCommand); @@ -85,8 +85,8 @@ static char *ConsoleCompleteHelper(const char *word, int state) } { - ObjectLock olock(l_ScriptFrame.Locals); - BOOST_FOREACH(const Dictionary::Pair& kv, l_ScriptFrame.Locals) { + ObjectLock olock(l_ScriptFrame->Locals); + BOOST_FOREACH(const Dictionary::Pair& kv, l_ScriptFrame->Locals) { AddSuggestion(matches, word, kv.first); } } @@ -109,7 +109,7 @@ static char *ConsoleCompleteHelper(const char *word, int state) Expression *expr = ConfigCompiler::CompileText("temp", pword, false); if (expr) - value = expr->Evaluate(l_ScriptFrame); + value = expr->Evaluate(*l_ScriptFrame); if (value.IsObjectType()) { Dictionary::Ptr dict = value; @@ -164,6 +164,9 @@ int ConsoleCommand::Run(const po::variables_map& vm, const std::vector(); @@ -176,7 +179,7 @@ int ConsoleCommand::Run(const po::variables_map& vm, const std::vectorEvaluate(l_ScriptFrame); + Value result = expr->Evaluate(scriptFrame); std::cout << ConsoleColorTag(Console_ForegroundCyan); if (!result.IsObject() || result.IsObjectType() || result.IsObjectType()) std::cout << JsonEncode(result);