8000 bug #52941 [Console] Fix xterm detection (theofidry) · symfony/symfony@57f60d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 57f60d0

Browse files
committed
bug #52941 [Console] Fix xterm detection (theofidry)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] Fix xterm detection | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | None reported | License | MIT Currently `StreamOutput::hasColorSupport()` returns `true` if `TERM=xterm`. However xterm may have different values such as `xterm-256color`. Technically I think it would be more correct to check `xterm` or starts with `xterm-`, but I am not convinced there is a need to do so and one may prefer the (tiny) performance advantage? This can easily be changed though. Commits ------- 109c088 fix xterm detection
2 parents 4496b59 + 109c088 commit 57f60d0

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ public function getStream()
6464
return $this->stream;
6565
}
6666

67-
/**
68-
* {@inheritdoc}
69-
*/
7067
protected function doWrite(string $message, bool $newline)
7168
{
7269
if ($newline) {
@@ -103,7 +100,7 @@ protected function hasColorSupport()
103100
&& @sapi_windows_vt100_support($this->stream))
104101
|| false !== getenv('ANSICON')
105102
|| 'ON' === getenv('ConEmuANSI')
106-
|| 'xterm' === getenv('TERM');
103+
|| str_starts_with((string) getenv('TERM'), 'xterm');
107104
}
108105

109106
return 'Hyper' === getenv('TERM_PROGRAM')

0 commit comments

Comments
 (0)
0