From f7f81892a0df39e27d75a47cec74806a49b93f0f Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Tue, 20 Mar 2018 15:40:39 +0100 Subject: [PATCH] Fix check of color support on Windows If the stream is redirected, the script should behave the same on Windows and on POSIX systems. --- .../Component/Console/Output/StreamOutput.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Output/StreamOutput.php b/src/Symfony/Component/Console/Output/StreamOutput.php index d36e6f9560159..182622a29a5c8 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -81,17 +81,26 @@ protected function doWrite($message, $newline) * * Colorization is disabled if not supported by the stream: * - * - Windows != 10.0.10586 without Ansicon, ConEmu or Mintty + * - the stream is redirected (eg php file.php >log) + * - Windows without VT100 support, Ansicon, ConEmu, Mintty * - non tty consoles * * @return bool true if the stream supports colorization, false otherwise */ protected function hasColorSupport() { + if (function_exists('stream_isatty') && !@stream_isatty($this->stream)) { + return false; + } if (DIRECTORY_SEPARATOR === '\\') { + if (function_exists('sapi_windows_vt100_support')) { + $vt100Enabled = @sapi_windows_vt100_support($this->stream); + } else { + $vt100Enabled = '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD; + } + return - function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support($this->stream) - || '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD + $vt100Enabled || false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy