Fix case where dict doesn't return anything
authorMikael Berthe <mikael@lilotux.net>
Tue, 01 Jun 2010 16:41:49 +0200
changeset 42 99477d3c2dda
parent 41 5c0a2db896f5
child 43 7f9ecc483f73
Fix case where dict doesn't return anything
mcbot/cmds/dict.lua
--- a/mcbot/cmds/dict.lua	Sun May 16 13:43:31 2010 +0200
+++ b/mcbot/cmds/dict.lua	Tue Jun 01 16:41:49 2010 +0200
@@ -11,7 +11,7 @@
     local fh = io.popen(cmd)
     result = fh:read("*a")  -- read dict output
     fh:close()
-    if result:match("^$") then return nil, "dict: No output" end
+    if not result or result:match("^$") then return nil, "dict: No output" end
 
     -- Sometimes dict outpur is ugly... Let's filter out whitespace.
     result = result:gsub("[ \t]+\n", "\n"):gsub("\n\n\n+", "\n\n")