Skip to content

[Console] reopen inputStream after a ctrl+D/ctrl+Z #38345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
reopen inputStream after a ctrl+D/ctrl+Z
  • Loading branch information
epitre committed Sep 29, 2020
commit 1165217c1ef8e4375f3b0d9abf5f48475e5b4e5f
1 change: 1 addition & 0 deletions src/Symfony/Component/Console/Helper/QuestionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ private function readInput($inputStream, Question $question)
while (false !== ($char = fgetc($inputStream))) {
$ret .= $char;
}
$this->inputStream = fopen('php://stdin', 'r');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the input stream being used is not php://stdin ? That's a supported use case (see isInteractiveInput supporting that case explicitly for instance).

Also, this method looks like the wrong place to me, as it is not designed to use $this->inputStream directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very valid point.
I have no idea how to deal with it ^^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have a solution. I'm testing it on Windows to make sure it works there, as well.


return $ret;
}
Expand Down