bug #15915 Detect Mintty for color support on Windows (stof)

This PR was submitted for the 2.8 branch but it was merged into the 2.3 branch instead (closes #15915).

Discussion
----------

Detect Mintty for color support on Windows

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/5726

Mintty is now the default terminal in GitBash, and it supports ANSI colors without the need of ANSICON (it even supports 256 colors rather than the 16 colors supported by ANSICON).

I submitted it to 2.8 as it can be considered as a new feature. But it should not be hard to merge it in other branches if we decide to consider it as a bugfix (it just needs to be split because VarDumper does not exist in 2.3)

Commits
-------

12743d1 Detect Mintty for color support on Windows
This commit is contained in:
Fabien Potencier 2015-09-27 11:59:16 +02:00
commit 4a8935597c
1 changed files with 2 additions and 2 deletions

View File

@ -89,7 +89,7 @@ class StreamOutput extends Output
*
* Colorization is disabled if not supported by the stream:
*
* - Windows without Ansicon and ConEmu
* - Windows without Ansicon, ConEmu or Mintty
* - non tty consoles
*
* @return bool true if the stream supports colorization, false otherwise
@ -98,7 +98,7 @@ class StreamOutput extends Output
{
// @codeCoverageIgnoreStart
if (DIRECTORY_SEPARATOR === '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
}
return function_exists('posix_isatty') && @posix_isatty($this->stream);