summaryrefslogtreecommitdiff
path: root/src/command_manager.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-02-15 14:19:57 +0000
committerMaxime Coste <frrrwww@gmail.com>2012-02-15 14:19:57 +0000
commit91f2292ec5a0aa6c6fe57b975fbc1cc87b7291c4 (patch)
tree0dbb352f0835b6d12505c3dad416b59137d35857 /src/command_manager.cc
parente9af61eb9f7211a4d901c383772c46634cfbfc20 (diff)
Support shell expansion in place of command name in command manager
Diffstat (limited to 'src/command_manager.cc')
-rw-r--r--src/command_manager.cc16
1 files changed, 15 insertions, 1 deletions
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<std::string> 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<std::string> expanded_params;
for (auto param = begin+1; param != end; ++param)
{
if (param->front() == '`' and param->back() == '`')