Skip to content

Commit

Permalink
[Console] fix "data lost during stream conversion" with QuestionHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed May 5, 2020
1 parent 2732dda commit 6d089ac
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Symfony/Component/Console/Helper/QuestionHelper.php
Expand Up @@ -462,10 +462,6 @@ private function validateAttempts(callable $interviewer, OutputInterface $output
$error = null;
$attempts = $question->getMaxAttempts();

if (null === $attempts && !$this->isTty()) {
$attempts = 1;
}

while (null === $attempts || $attempts--) {
if (null !== $error) {
$this->writeError($output, $error);
Expand All @@ -477,6 +473,8 @@ private function validateAttempts(callable $interviewer, OutputInterface $output
throw $e;
} catch (\Exception $error) {
}

$attempts = $attempts ?? -(int) $this->isTty();
}

throw $error;
Expand Down Expand Up @@ -517,7 +515,7 @@ private function isTty(): bool
return stream_isatty($inputStream);
}

if (!\function_exists('posix_isatty')) {
if (\function_exists('posix_isatty')) {
return posix_isatty($inputStream);
}

Expand Down

0 comments on commit 6d089ac

Please sign in to comment.