Skip to content

Commit d82e498

Browse files
committed
fix: Correctly check color support
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.
1 parent a314b65 commit d82e498

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,17 @@ protected function hasColorSupport(): bool
9797
return false;
9898
}
9999

100-
if ('Hyper' === getenv('TERM_PROGRAM')) {
100+
if (\DIRECTORY_SEPARATOR === '\\'
101+
&& \function_exists('sapi_windows_vt100_support'
102+
&& @sapi_windows_vt100_support($this->stream)
103+
) {
101104
return true;
102105
}
103106

104-
if (\DIRECTORY_SEPARATOR === '\\') {
105-
return (\function_exists('sapi_windows_vt100_support')
106-
&& @sapi_windows_vt100_support($this->stream))
107-
|| false !== getenv('ANSICON')
108-
|| 'ON' === getenv('ConEmuANSI')
109-
|| 'xterm' === getenv('TERM');
110-
}
111-
112-
return stream_isatty($this->stream);
107+
return 'Hyper' === getenv('TERM_PROGRAM')
108+
|| false !== getenv('ANSICON')
109+
|| 'ON' === getenv('ConEmuANSI')
110+
|| 'xterm' === getenv('TERM')
111+
|| stream_isatty($this->stream);
113112
}
114113
}

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