svn commit: r353873 - head/stand/lua

Kyle Evans kevans at FreeBSD.org
Mon Oct 21 20:17:32 UTC 2019


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


More information about the svn-src-head mailing list