Skip to content

TERM and NO_COLOR envirnoment vars still not respected #21160

@ghost

Description

Prerequisites

Steps to reproduce

As per "Enable use of TERM and NO_COLOR env var plaintext #14969" the TERM and NO_COLOR variables should disable coloring of errors in pwsh. But executing the showbug.bat in command.exe in the root directory of pwsh version 7 4 1 with this content:

pwsh.exe -ExecutionPolicy Unrestricted ^
   -Command "$host.version ; " ^
   "Get-Item  Env:TERM ; " ^
   "Get-Item  Env:NO_COLOR ; " ^
   "Get-It1"

Shows:

 Major  Minor  Build  Revision
 -----  -----  -----  --------
 7      4      1      -1
 
 PSPath        : Microsoft.PowerShell.Core\Environment::TERM
 PSDrive       : Env
 PSProvider    : Microsoft.PowerShell.Core\Environment
 PSIsContainer : False
 Key           : TERM
 Value         : xterm-mono
 Name          : TERM
 
 
 PSPath        : Microsoft.PowerShell.Core\Environment::NO_COLOR
 PSDrive       : Env
 PSProvider    : Microsoft.PowerShell.Core\Environment
 PSIsContainer : False
 Key           : NO_COLOR
 Value         : True
 Name          : NO_COLOR
 
 Get-It1: The term 'Get-It1' is not recognized as a name of a cmdlet, function, script file, or executable program.
 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Here, the error message, triggered intentionally to demonstrate the bug, is RED colored.

Expected behavior

The error message should be printed without the colors.

Actual behavior

The error is RED colored, in spite of the environment variables requesting no colors and being clearly readable by the pwsh.exe.

Error details

The error in the above example is triggered intentionally to show that the error message is colored RED.
The error here is that the error message itself is displayed using colors, which is not what is supposed to happen according to the #14969

Environment data

PS C:\tmp\pwsh741> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 6.3.9600
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

pwsh74bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions