lualoader: fix setting of loader_color=NO in loader.conf(5)

Previously color.disabled would be calculated at color module load time,
then never touched again. We can detect serial boots beyond just what we're
told by loader.conf(5) so this works out in many cases, but we must
re-evaluate the situation after the config is loaded to make sure we're not
supposed to be forcing it enabled/disabled.

Discovered while trying to test r353872.
This commit is contained in:
kevans 2019-10-21 20:17:31 +00:00
parent 3c286dfb69
commit faec23395b

View File

@ -29,9 +29,14 @@
--
local core = require("core")
local hook = require("hook")
local color = {}
local function recalcDisabled()
color.disabled = not color.isEnabled()
end
-- Module exports
color.BLACK = 0
color.RED = 1
@ -54,8 +59,6 @@ function color.isEnabled()
return not core.isSerialBoot()
end
color.disabled = not color.isEnabled()
function color.escapefg(color_value)
if color.disabled then
return ''
@ -113,4 +116,7 @@ function color.highlight(str)
return core.KEYSTR_CSI .. "1m" .. str .. core.KEYSTR_CSI .. "22m"
end
recalcDisabled()
hook.register("config.loaded", recalcDisabled)
return color