Author: kevans
Date: Sun Oct  6 04:02:29 2019
New Revision: 353137
URL: https://svnweb.freebsd.org/changeset/base/353137

Log:
  MFC r352559: loader: Respect loader_color=YES for serial consoles
  
  It's not uncommon these days for the terminals attached to serial consoles
  to support ANSI escape sequences. However, we assume escape sequences may
  break some serial consoles and default to not using them when boot_serial or
  boot_multicons (or if console contains "comconsole" in the forth loader) for
  broader compatibility. We also have loader_color which can be explicitly set
  to "NO" to disable the use of ANSI escape sequences.
  
  The problem is that loader_color=YES gets ignored when boot_serial=YES or
  boot_multicons=YES (or when console contains "comconsole" in the forth
  loader).
  
  To fix, the existing default behavior remains unchanged when loader_color is
  unset, loader_color=NO explicitly disables the use of ANSI escape sequences
  still, and the change is that loader_color=YES can now be used to explicitly
  allow ANSI escapes when a serial console is enabled.

Modified:
  stable/12/stand/forth/color.4th
  stable/12/stand/lua/color.lua
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/stand/forth/color.4th
  stable/11/stand/lua/color.lua
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/stand/forth/color.4th
==============================================================================
--- stable/12/stand/forth/color.4th     Sun Oct  6 04:01:15 2019        
(r353136)
+++ stable/12/stand/forth/color.4th     Sun Oct  6 04:02:29 2019        
(r353137)
@@ -27,12 +27,14 @@
 marker task-color.4th
 
 \ This function returns FALSE if the `loader_color' environment variable is set
-\ to NO, no, or 0. Otherwise, TRUE is returned (unless booting serial).
+\ to NO, no, or 0. It returns TRUE if `loader_color' is set to any other value.
+\ If `loader_color' is unset, TRUE is returned (unless booting serial).
 \ 
-: loader_color? ( -- N )
+: loader_color? ( -- t )
 
        s" loader_color" getenv dup -1 <> if
-
+               \ `loader_color' is set.
+               \ Check if it is explicitly disabled.
                2dup s" NO" compare-insensitive 0= if
                        2drop
                        FALSE exit
@@ -42,8 +44,12 @@ marker task-color.4th
                        FALSE exit
                then
                drop
+               \ It is enabled.
+               TRUE
+       else
+               \ `loader_color' is unset.
+               \ Default to using color unless serial boot is active.
+               drop
+               boot_serial? 0=
        then
-       drop
-
-       boot_serial? if FALSE else TRUE then
 ;

Modified: stable/12/stand/lua/color.lua
==============================================================================
--- stable/12/stand/lua/color.lua       Sun Oct  6 04:01:15 2019        
(r353136)
+++ stable/12/stand/lua/color.lua       Sun Oct  6 04:02:29 2019        
(r353137)
@@ -49,9 +49,7 @@ color.DIM     = 2
 function color.isEnabled()
        local c = loader.getenv("loader_color")
        if c ~= nil then
-               if c:lower() == "no" or c == "0" then
-                       return false
-               end
+               return c:lower() ~= "no" and c ~= "0"
        end
        return not core.isSerialBoot()
 end
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to