Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b8174d1

Browse files
Forward-port #3764 (stty size fix) to master (#3772)
1 parent 049d2a4 commit b8174d1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Config/Environment.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,13 @@ public function calculateColumns()
456456

457457
// Trying to export the columns using stty.
458458
exec('stty size 2>&1', $columns_output, $columns_status);
459-
if (!$columns_status) {
460-
$columns = preg_replace('/\d+\s(\d+)/', '$1', $columns_output[0], -1, $columns_count);
459+
$matched = false;
460+
if (!$columns_status && $matched = preg_match('/^\d+\s(\d+)$/', $columns_output[0], $matches, 0)) {
461+
$columns = $matches[1];
461462
}
462463

463464
// If stty fails and Drush us running on Windows are we trying with mode con.
464-
if (($columns_status || !$columns_count) && static::isWindows()) {
465+
if (($columns_status || !$matched) && static::isWindows()) {
465466
$columns_output = [];
466467
exec('mode con', $columns_output, $columns_status);
467468
if (!$columns_status && is_array($columns_output)) {

0 commit comments

Comments
 (0)