Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bb8c82c

Browse filesBrowse files
nicolas-grekaschalasr
authored andcommitted
[Console] Constant STDOUT might be undefined.
1 parent 7064ff3 commit bb8c82c
Copy full SHA for bb8c82c

File tree

1 file changed

+14
-1
lines changed
Filter options

1 file changed

+14
-1
lines changed

‎src/Symfony/Component/Console/Terminal.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Terminal.php
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ private static function initDimensions()
7979
// or [w, h] from "wxh"
8080
self::$width = (int) $matches[1];
8181
self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
82-
} elseif (self::hasSttyAvailable()) {
82+
} elseif (!self::hasVt100Support() && self::hasSttyAvailable()) {
83+
// only use stty on Windows if the terminal does not support vt100 (e.g. Windows 7 + git-bash)
84+
// testing for stty in a Windows 10 vt100-enabled console will implicitly disable vt100 support on STDOUT
8385
self::initDimensionsUsingStty();
8486
} elseif (null !== $dimensions = self::getConsoleMode()) {
8587
// extract [w, h] from "wxh"
@@ -91,6 +93,17 @@ private static function initDimensions()
9193
}
9294
}
9395

96+
/**
97+
* Returns whether STDOUT has vt100 support (some Windows 10+ configurations).
98+
*/
99+
private static function hasVt100Support()
100+
{
101+
return \function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'w'));
102+
}
103+
104+
/**
105+
* Initializes dimensions using the output of an stty columns line.
106+
*/
94107
private static function initDimensionsUsingStty()
95108
{
96109
if ($sttyString = self::getSttyColumns()) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.