# HG changeset patch # User Matthew Wild # Date 1702042611 0 # Node ID de6c1a170871d0405ed803511379b21b7b46e229 # Parent e5ddae99faa8f27206090529c7f5cf3611992919 configmanager: Allow referencing previously-set options in the config file diff -r e5ddae99faa8 -r de6c1a170871 core/configmanager.lua --- a/core/configmanager.lua Thu Dec 07 12:08:01 2023 +0000 +++ b/core/configmanager.lua Fri Dec 08 13:36:51 2023 +0000 @@ -62,6 +62,16 @@ return false; end +local function rawget_option(config_table, host, key) + if host and key then + local hostconfig = rawget(config_table, host); + if not hostconfig then + return nil; + end + return rawget(hostconfig, key); + end +end + function _M.set(host, key, value) return set(config, host, key, value); end @@ -119,6 +129,10 @@ if k:match("^ENV_") then return os.getenv(k:sub(5)); end + local val = rawget_option(config_table, env.__currenthost or "*", k); + if val ~= nil then + return val; + end return rawget(_G, k); end, __newindex = function (_, k, v)