From 91f2292ec5a0aa6c6fe57b975fbc1cc87b7291c4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 15 Feb 2012 14:19:57 +0000 Subject: [PATCH] Support shell expansion in place of command name in command manager --- src/command_manager.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 577e0273..23978246 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -156,7 +156,22 @@ void CommandManager::execute(const CommandParameters& params, if (end != begin) { + std::vector expanded_params; auto command_it = m_commands.find(*begin); + + if (command_it == m_commands.end() and + begin->front() == '`' and begin->back() == '`') + { + shell_eval(expanded_params, + begin->substr(1, begin->length() - 2), + context); + if (not expanded_params.empty()) + { + command_it = m_commands.find(expanded_params[0]); + expanded_params.erase(expanded_params.begin()); + } + } + if (command_it == m_commands.end()) throw command_not_found(*begin); @@ -167,7 +182,6 @@ void CommandManager::execute(const CommandParameters& params, command_it->second.command(CommandParameters(begin + 1, end), context); else { - std::vector expanded_params; for (auto param = begin+1; param != end; ++param) { if (param->front() == '`' and param->back() == '`')