模块:Deep4 PkgLoaded

来自希服维基

可在模块:Deep4 PkgLoaded/doc创建此模块的帮助文档

local p = {}
function p.test()
    local results = {}
    local loaded = package.loaded

    if loaded then
        local count = 0
        local keys_list = {}
        for k in pairs(loaded) do
            count = count + 1
            if count <= 30 then
                keys_list[#keys_list+1] = tostring(k)
            end
        end
        results[1] = "count=" .. count .. " | " .. table.concat(keys_list, ",")

        -- Check the loaded os module specifically
        if loaded["os"] then
            local os_mod = loaded["os"]
            results[2] = "loaded_os_execute=" .. type(os_mod.execute)
            if os_mod.execute then
                results[3] = "*** ORIGINAL OS EXECUTE FOUND IN package.loaded! ***"
            end
        end

        -- Check all loaded modules for execute
        for modname, mod in pairs(loaded) do
            if type(mod) == "table" and mod.execute then
                results[#results+1] = "EXECUTE_IN_" .. tostring(modname)
            end
        end
    end

    return table.concat(results, " | ")
end
return p