Page MenuHomePhabricator

ANSI color escape sequences seem broken for arc in git bash on windows
Open, LowPublic


I installed arc on a windows box. Installing php and cloning the repositories worked fine. Also arc runs fine. However arc tries to output escape sequences for coloring its output which for some reason does not work correctly:

$ arc help
      ←[1marc←[m - arcanist, a code review and revision management utility

      ←[1marc←[m ←[4mcommand←[m [←[4moptions←[m] [←[4margs←[m]
      This help file provides a detailed command reference.

Colors work fine for my git bash prompt. Colors work also fine when doing arc help|cat. - I'm not sure what is going on there.

Event Timeline

michas2 raised the priority of this task from to Low.
michas2 updated the task description. (Show Details)
michas2 added a project: Arcanist.
michas2 added a subscriber: michas2.
epriestley added a subscriber: epriestley.

We should emit color sequences on Windows only if:

  • your TERM environmental variable is set to cygwin or ansi; or
  • your ANSICON environmental variable is set and your TERM environmental variable is empty.


  • Which terminal (e.g., cygwin, msys/mingw, git bash, cmd.exe, powershell?) are you experiencing problems with?
  • What are the values of your TERM and ANSICON environmental variables in that terminal?
epriestley renamed this task from Escape sequences seem broken for arc in git bash on windows to ANSI color escape sequences seem broken for arc in git bash on windows.Aug 12 2014, 10:46 AM

It's a standard git-bash installation, i.e. a bash running in a cmd window. TERM is set to "cygwin".

After a bit more of debugging it seem to be some kind of issue in php:

This works fine, i.e. "red" gets printed in red:

$ echo -e "normal\033[31mred\033[mnormal"

However this does not:

$ cat t.php
  print "normal\033[31mred\033[mnormal";
$ php t.php

But again this works:

$ php t.php|cat

Either php needs some kind of option to output "correct" escape sequences, or echo and cat is smart enough to transform the usual escape sequences into something understandable by the cmd window.

The same problem is reproducible with java:

class T{
  public static void main(String[] args){

It will behave exactly like the php version. - Seems like there is some magic in echo and cat which actually transforms the escape sequences into the correct format.

Hi All,
The "Arcanist User Guide: Windows" page explicitly calls out in the first sentence that arcanist is intended to work in git bash. However, this bug makes it pretty unusable in that environment. Can you guys perhaps change the docs to reflect that it's not intended to work there? Also, for extra bonus points, add a link to this bug.

(Alternatively, perhaps this bug can be prioritized and addressed? I'm not sure what your workflow is like but "Assigned To: None, Priority: Low" seems to indicate it's not bubbled to the top of anyone's to-do list.)

I ran into the same issue with the default install of git-bash on Windows (8.1 x64), I ended up adding a function to my bash profile as per @michas2 idea:

function arc(){
    command arc $@|cat

Definitely very hack-ish but does the trick quickly. (you may also use echo -e instead of cat)
You can have a more detailed explanation of my adventures here:
Using Arcanist CLI tool with Git-Bash

Seeing this issue on the following machine:

Git-Bash (unixy color codes appear in the output, doesn't actually color the text)
ANSICON (undefined)

cmd.exe (no color codes appear in output, no text is colorized)
TERM (undefined)
ANSICON (undefined)

This also happens on a normal arc install running on Powershell, except that I can't do any of the git_bash workarounds. I have git harnessed through Github's git shell. I'm synced with the most recent php/arcanist as of 12/30/15.

Platform: Win10 powershell
TERM: cygwin

C:\Users\Melissa\src [master]> $env:TERM="cygwin"
C:\Users\Melissa\src [master]> arc
←[1mUsage Exception:←[m Unknown command '--'. Try 'arc help'.
C:\Users\Melissa\src [master]> $env:TERM="msys"
C:\Users\Melissa\src [master]> arc
Usage Exception: Unknown command '--'. Try 'arc help'.