Bug 3290 - Color extension does not work on Windows with a shell other than cmd.exe
Summary: Color extension does not work on Windows with a shell other than cmd.exe
Status: RESOLVED WONTFIX
Alias: None
Product: Mercurial
Classification: Unclassified
Component: color (show other bugs)
Version: unspecified
Hardware: PC Windows
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-28 03:17 UTC by jeberger
Modified: 2013-08-12 13:23 UTC (History)
6 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jeberger 2012-02-28 03:17 UTC
When using zsh in Console2 on Windows, the colour extension tries to output
ANSI colour codes instead of using the win32 API. When forcing
color.mode=win32, it works but I get a warning ("warning: failed to set
color mode to win32") if I try to send the output of hg through a pipe.

I've currently worked around the issue by forcing color.mode=win32 and
commenting out the warning in hgext/color.py:179
Comment 1 Bugzilla 2012-05-12 09:28 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:28 EDT  ---

This bug was previously known as _bug_ 3289 at http://mercurial.selenic.com/bts/issue3289

Bug Status was UNCONFIRMED but everconfirmed was true
   Setting status to CONFIRMED

Comment 2 brodie 2012-05-17 07:09 UTC
OK, just to confirm:

- You don't get any colorization by default.

- If you run hg with color.mode=win32 and you *don't* pipe hg's output, you don't get any warnings from color and colorization works correctly.

- If you run hg with color.mode=win32 and you *dO pipe hg's output, you get a warning from color and no colorization occurs.

Is that right?

If so, can you run echo $TERM and paste the output? If you've exported TERM (or if Console2 is doing that), that might be the cause of the first problem.

The piping problem sounds like a separate issue.
Comment 3 jeberger 2012-05-17 07:56 UTC
(In reply to comment #2)
That is correct. I should add that by default, there is no colorization but there are ANSI escape codes mixed with the output (codes like: "^[01;31m").

I'll check the value of TERM when I get back on the Windows computer on Monday.
Comment 4 Matt Mackall 2013-07-27 19:35 UTC
Unassign some bugs with no activity.
Comment 5 jeberger 2013-08-12 05:25 UTC
It looks like zsh is exporting TERM=vt100:

- Running "echo $TERM" in zsh prints "vt100" in Console2 as well as in the default windows console (cmd.exe).

- Running "echo %TERM%" in cmd.exe prints "%TERM%" in Console2 as well as in the default console.

- Searching for "vt100" in my configuration files does not find anything.
Comment 6 Matt Mackall 2013-08-12 13:23 UTC
I don't think this is something we should fix on our end.

If TERM is set, we should honor it, and we appear to be doing that.

There are ways to get the color codes to work:

http://linge-ma.ws/2011/08/better-cmd-exe-terminal-and-ansi-color-codes-support/