Skip to content

Commit 007fa61

Browse files
committed
Refactor isTtySupported()
1 parent 5bc5827 commit 007fa61

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/Symfony/Component/Console/Cursor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ public function getCurrentPosition(): array
183183
{
184184
static $isTtySupported;
185185

186-
if (null === $isTtySupported && \function_exists('proc_open')) {
187-
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
186+
if (null === $isTtySupported) {
187+
$isTtySupported = ('/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT));
188188
}
189189

190190
if (!$isTtySupported) {

src/Symfony/Component/Console/Tests/CursorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public function testGetCurrentPosition()
184184
$this->assertEquals("\x1b[11;10H", $this->getOutputContent($output));
185185

186186
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
187+
$this->assertEquals($isTtySupported, '/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT));
187188

188189
if ($isTtySupported) {
189190
// When tty is supported, we can't validate the exact cursor position since it depends where the cursor is when the test runs.

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ public static function isTtySupported(): bool
12051205
static $isTtySupported;
12061206

12071207
if (null === $isTtySupported) {
1208-
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
1208+
$isTtySupported = ('/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT));
12091209
}
12101210

12111211
return $isTtySupported;

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