From 1ce57df2316f39d7c9b5fa4127041c6e034089aa Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Mon, 21 Oct 2019 20:17:31 +0000 Subject: [PATCH] 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. --- stand/lua/color.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stand/lua/color.lua b/stand/lua/color.lua index 870e921e2f77..364d548ca3dc 100644 --- a/stand/lua/color.lua +++ b/stand/lua/color.lua @@ -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