plugins/mod_console.lua

changeset 1317
f6e56a555c37
parent 1316
28ae044f1aaf
child 1322
33d103b0283f
--- a/plugins/mod_console.lua	Fri Jun 05 20:18:19 2009 +0100
+++ b/plugins/mod_console.lua	Fri Jun 05 20:18:55 2009 +0100
@@ -56,6 +56,8 @@
 	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 @@
 					return;
 				end
 			end
+
+			if data:match("^>") then
+				data = data:gsub("^>", "");
+				useglobalenv = true;
+			end
 			
 			session.env._ = data;
 			
@@ -79,7 +86,8 @@
 				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

mercurial