Date: Mon, 21 Oct 2019 20:17:31 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353873 - head/stand/lua Message-ID: <201910212017.x9LKHVx9044761@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Mon Oct 21 20:17:31 2019 New Revision: 353873 URL: https://svnweb.freebsd.org/changeset/base/353873 Log: 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. Modified: head/stand/lua/color.lua Modified: head/stand/lua/color.lua ============================================================================== --- head/stand/lua/color.lua Mon Oct 21 20:09:43 2019 (r353872) +++ head/stand/lua/color.lua Mon Oct 21 20:17:31 2019 (r353873) @@ -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 '' @@ -112,5 +115,8 @@ function color.highlight(str) -- case the terminal defaults don't match what we're expecting. return core.KEYSTR_CSI .. "1m" .. str .. core.KEYSTR_CSI .. "22m" end + +recalcDisabled() +hook.register("config.loaded", recalcDisabled) return color
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910212017.x9LKHVx9044761>