aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-07-09 04:34:55 +0100
committerMatthew Wild <mwild1@gmail.com>2009-07-09 04:34:55 +0100
commit46b622576dd029af33faa1d66130056b4fa8362c (patch)
treed501d8762a42de5ee53714986586931b139aa6b2
parent453b76ef8c1a84e893bf88887672587a4c4048b8 (diff)
downloadprosody-46b622576dd029af33faa1d66130056b4fa8362c.tar.gz
prosody-46b622576dd029af33faa1d66130056b4fa8362c.zip
mod_console: Check for commands when not executing in the global environment
-rw-r--r--plugins/mod_console.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua
index 0d6b5e41..556f0c5d 100644
--- a/plugins/mod_console.lua
+++ b/plugins/mod_console.lua
@@ -65,7 +65,10 @@ function console_listener.listener(conn, data)
(function(session, data)
local useglobalenv;
- if data:match("[!.]$") then
+ if data:match("^>") then
+ data = data:gsub("^>", "");
+ useglobalenv = true;
+ else
local command = data:lower();
command = data:match("^%w+") or data:match("%p");
if commands[command] then
@@ -74,11 +77,6 @@ function console_listener.listener(conn, data)
end
end
- if data:match("^>") then
- data = data:gsub("^>", "");
- useglobalenv = true;
- end
-
session.env._ = data;
local chunk, err = loadstring("return "..data);
@@ -97,6 +95,11 @@ function console_listener.listener(conn, data)
local ranok, taskok, message = pcall(chunk);
+ if not (ranok or message or useglobalenv) and commands[data:lower()] then
+ commands[data:lower()](session, data);
+ return;
+ end
+
if not ranok then
session.print("Fatal error while running command, it did not complete");
session.print("Error: "..taskok);