Skip to content

ANSI escape color codes broken on Git Bash in Windows Terminal #19391

@tiesmaster

Description

@tiesmaster

Describe the bug
Running the az CLI on Windows using Git Bash in the Windows Terminal shows color output is broken. This is specific to this situation (see below for more context). When running $ az help, the output ends with:

[...more output elided for brevity...]
←[1mFor more specific examples, use: az find "az "←[0m

←[0mPlease let us know how we are doing: ←[96mhttps://aka.ms/azureclihats←[0m
←[0mand let us know if you're interested in trying out our newest features: ←[96mhttps://aka.ms/CLIUXstudy←[0m

To Reproduce

  1. Install latest Windows Terminal
  2. Install latest Git Bash, and enable the checkbox to add the "Windows Terminal" profile
  3. Install latest Azure CLI
  4. Start Windows Terminal, and open the Git Bash profile
  5. Run: $ az help

Expected behavior
Output is showing colors.

Environment summary

Windows-10-10.0.19041-SP0
Python 3.8.9
Installer: MSI

azure-cli 2.27.1

Windows Terminal
Version: 1.9.1942.0

Git for Windows: 2.33.0.2

Additional context
I ran into this when setting up a new dev box, and also found out the following details:

  • when starting the powershell profile within Windows Terminal, the output is colored correctly
  • when starting Git Bash from the Start Menu (this uses the mintty terminal that comes preinstalled with the Git for Windows install), the output is not colored, but the escape codes don't appear
  • when running the Azure CLI on my old system, the coloring output is working inside the Windows Terminal (same version) in Git Bash. The version of the Azure CLI that's installed there is: 2.15.1
  • running ANSI escape sequences like this does ouput colors

UPDATE: Results of some additional testing

I wanted to be sure that the reproduction steps are sound on a new system, with pretty much all the defaults, and installing from MSI, or Windows Store (for the Windows Terminal). So I created a new VM in Azure with Windows 10 Pro 20H2, and managed to reproduce this in this fresh box.

I also did some additional research where this broke, so I did a "git bisect" but then via installing the MSIs, and there are my results:

  • 2.18: PASS
  • 2.20: PASS
  • 2.21: PASS
  • 2.22: FAIL
  • 2.23: FAIL
  • 2.27.2: FAIL

Needless to say, version 2.22 broke this.

Metadata

Metadata

Assignees

Labels

CoreCLI core infrastructurecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions