Skip to content

Commit 7121397

Browse files
committed
bug #52940 [Console] Fix color support check on non-Windows platforms (theofidry)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] Fix color support check on non-Windows platforms | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #45917 | License | MIT Currently checking the color support based on `ANSICON`, `ConEmuANSI=ON` or `TERM=xTerm` is done only for Widows. I could not find any reason as to why and it does not make much sense as it is. Especially if we consider that `TERM=xTerm` is a term check and we do another one (not Widows specific) which is `TERM_PROGRAM=Hyper`. This potentially fixes #45917. This also looks more in line with the intent (based on the title) of #27831 and #27794. Commits ------- 285518d detect colors on not windows
2 parents 8c56020 + 285518d commit 7121397

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@ protected function hasColorSupport()
9595
return false;
9696
}
9797

98-
if (\DIRECTORY_SEPARATOR === '\\') {
99-
return (\function_exists('sapi_windows_vt100_support')
100-
&& @sapi_windows_vt100_support($this->stream))
101-
|| false !== getenv('ANSICON')
102-
|| 'ON' === getenv('ConEmuANSI')
103-
|| str_starts_with((string) getenv('TERM'), 'xterm');
98+
if (\DIRECTORY_SEPARATOR === '\\'
99+
&& \function_exists('sapi_windows_vt100_support')
100+
&& @sapi_windows_vt100_support($this->stream)
101+
) {
102+
return true;
104103
}
105104

106105
return 'Hyper' === getenv('TERM_PROGRAM')
106+
|| false !== getenv('ANSICON')
107+
|| 'ON' === getenv('ConEmuANSI')
108+
|| str_starts_with((string) getenv('TERM'), 'xterm')
107109
|| stream_isatty($this->stream);
108110
}
109111
}

0 commit comments

Comments
 (0)
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