plugins/mod_console.lua

changeset 1502
0f895c06e03f
parent 1496
4fa337035f46
child 1503
5970e06d9335
--- a/plugins/mod_console.lua	Wed Jul 08 16:53:59 2009 +0100
+++ b/plugins/mod_console.lua	Thu Jul 09 04:34:55 2009 +0100
@@ -65,7 +65,10 @@
 		(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 @@
 				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 @@
 			
 			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);

mercurial