Skip to content

Bug: Automatic no CLI colors for Windows terminals #2849

Description

@paulbalandan

Describe the bug
CLI::color() outright returns an unformatted text when running on Windows. It explicitly requires that $_SERVER['ANSICON'] be set to return a formatted text.

Modern Windows machines now natively supports VT100 Sequences by default starting with Win 10. As such, I believe Windows terminal are deprived to display colors.

I am thinking of adding checks for php's sapi_windows_vt100_support() or stream_isatty() to check the stream first. The only problem I see is that it is currently not testable with the current setup of the unit test since it is using filtered streams and those two methods don't support that. Also, the streams (STDOUT, STDERR) to test are tightly coupled in the code.

CodeIgniter 4 version
4.0.2
4.0-develop

Affected module(s)
CLI::color()

Expected behavior, and steps to reproduce if appropriate
In a Windows environment, run any CLI::color() with provided foreground and/or background. Example:

CLI::color('test', 'white', 'red');

Context

  • OS: Windows 10 version 1909
  • Web server: Apache 2.4.43
  • PHP version 7.4.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions