From a7d5c56e52fbfa28d31e1aac3a2ddddc7103c846 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 10 Nov 2010 19:50:07 +0000 Subject: configmanager: Update Include and RunScript directives to support paths relative to the (current!) config file --- core/configmanager.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/configmanager.lua b/core/configmanager.lua index b9618f86..edd1366a 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -145,7 +145,7 @@ do env = setmetatable({ Host = true, host = true, VirtualHost = true, Component = true, component = true, - Include = true, include = true, RunScript = dofile }, { + Include = true, include = true, RunScript = true }, { __index = function (t, k) return rawget(_G, k) or function (settings_table) @@ -205,6 +205,7 @@ do local f, err = io.open(file); if f then local data = f:read("*a"); + local file = resolve_relative_path(filename:gsub("[^"..path_sep.."]+$", ""), file); local ok, err = parsers.lua.load(data, file); if not ok then error(err:gsub("%[string.-%]", file), 0); end end @@ -213,6 +214,10 @@ do end env.include = env.Include; + function env.RunScript(file) + return dofile(resolve_relative_path(filename:gsub("[^"..path_sep.."]+$", ""), file)); + end + local chunk, err = loadstring(data, "@"..filename); if not chunk then -- cgit v1.2.3