|
20 | 20 | use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
21 | 21 | use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
22 | 22 | use Symfony\Component\Console\Output\OutputInterface;
|
| 23 | +use Symfony\Component\Console\Output\StreamOutput; |
23 | 24 | use Symfony\Component\Console\Question\ChoiceQuestion;
|
24 | 25 | use Symfony\Component\Console\Question\Question;
|
25 | 26 | use Symfony\Component\Console\Terminal;
|
@@ -462,7 +463,7 @@ private function validateAttempts(callable $interviewer, OutputInterface $output
|
462 | 463 | $error = null;
|
463 | 464 | $attempts = $question->getMaxAttempts();
|
464 | 465 |
|
465 |
| - if (null === $attempts && !$this->isTty()) { |
| 466 | + if (null === $attempts && !$this->isTty($output)) { |
466 | 467 | $attempts = 1;
|
467 | 468 | }
|
468 | 469 |
|
@@ -509,16 +510,22 @@ private function getShell()
|
509 | 510 | return self::$shell;
|
510 | 511 | }
|
511 | 512 |
|
512 |
| - private function isTty(): bool |
| 513 | + private function isTty(OutputInterface $output): bool |
513 | 514 | {
|
514 |
| - $inputStream = !$this->inputStream && \defined('STDIN') ? STDIN : $this->inputStream; |
| 515 | + if (!$output instanceof StreamOutput) { |
| 516 | + return true; |
| 517 | + } |
| 518 | + |
| 519 | + if (\DIRECTORY_SEPARATOR === '\\' && \function_exists('sapi_windows_vt100_support')) { |
| 520 | + return @sapi_windows_vt100_support($output->getSteam()); |
| 521 | + } |
515 | 522 |
|
516 | 523 | if (\function_exists('stream_isatty')) {
|
517 |
| - return stream_isatty($inputStream); |
| 524 | + return stream_isatty($output->getStream()); |
518 | 525 | }
|
519 | 526 |
|
520 | 527 | if (!\function_exists('posix_isatty')) {
|
521 |
| - return posix_isatty($inputStream); |
| 528 | + return posix_isatty($output->getStream()); |
522 | 529 | }
|
523 | 530 |
|
524 | 531 | return true;
|
|
0 commit comments