diff options
-rw-r--r-- | lib/clod.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/clod.lua b/lib/clod.lua index d9b4fde..952796c 100644 --- a/lib/clod.lua +++ b/lib/clod.lua @@ -358,12 +358,18 @@ local function parse_config(conf, confname, migrate_lists) last_entry = entry settings[key] = entry end - local func, msg = loadstring(conf, ("@%s"):format(confname or "clod-config")) - if not func then - return nil, msg - end + local func, msg + local sourcename = ("@%s"):format(confname or "clod-config") local globs = setmetatable({}, parse_mt) - setfenv(func, globs) + if setfenv == nil then + func, msg = load(conf, sourcename, "t", globs) + else + func, msg = loadstring(conf, sourcename) + if not func then + return nil, msg + end + setfenv(func, globs) + end local ok, err = pcall(func) if not ok then return nil, err |