aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_console.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mod_console.lua')
-rw-r--r--plugins/mod_console.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua
index bae106fd..c676c0eb 100644
--- a/plugins/mod_console.lua
+++ b/plugins/mod_console.lua
@@ -56,6 +56,8 @@ function console_listener.listener(conn, data)
if data then
-- Handle data
(function(session, data)
+ local useglobalenv;
+
if data:match("[!.]$") then
local command = data:lower();
command = data:match("^%w+") or data:match("%p");
@@ -64,6 +66,11 @@ function console_listener.listener(conn, data)
return;
end
end
+
+ if data:match("^>") then
+ data = data:gsub("^>", "");
+ useglobalenv = true;
+ end
session.env._ = data;
@@ -79,7 +86,8 @@ function console_listener.listener(conn, data)
end
end
- setfenv(chunk, session.env);
+ setfenv(chunk, (useglobalenv and _G) or session.env or nil);
+
local ranok, taskok, message = pcall(chunk);
if not ranok then