Skip to content

Commit

Permalink
bug #36696 [Console] don't check tty on stdin, it breaks with "data l…
Browse files Browse the repository at this point in the history
…ost during stream conversion" (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[Console] don't check tty on stdin, it breaks with "data lost during stream conversion"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

/cc @ostrolucky FYI

Commits
-------

6d089ac [Console] fix "data lost during stream conversion" with QuestionHelper
  • Loading branch information
fabpot committed May 5, 2020
2 parents 2732dda + 6d089ac commit cf6e499
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 cf6e499

Please sign in to comment.