1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 17:09:02 +00:00

New system for silent require errors. Use the new function

stdnse.silent_require. The Lua require function is back in its usual spot
(_G.require).
This commit is contained in:
batrick
2011-06-13 23:38:35 +00:00
parent e37cfc5d0e
commit dc9a35bc9d
14 changed files with 25 additions and 17 deletions

View File

@@ -212,8 +212,7 @@ local function tcopy (t)
end
local REQUIRE_ERROR = {};
stdnse.require = require; -- add real require to stdnse so it can be called if desired
function _G.require (...)
rawset(stdnse, "silent_require", function (...)
local status, mod = pcall(require, ...);
if not status then
print_debug(1, "%s", traceback(mod));
@@ -222,7 +221,7 @@ function _G.require (...)
else
return mod;
end
end
end);
local Script = {}; -- The Script Class, its constructor is Script.new.
local Thread = {}; -- The Thread Class, its constructor is Script:new_thread.