Skip to content

Commit

Permalink
Exit immediately if we're not in interactive mode and no input is pro…
Browse files Browse the repository at this point in the history
…vided

Previously we'd hang out trying to get input from readline, which is very much not what you'd expect if you explicitly asked for `--no-interaction` :)

See laravel/tinker#98
  • Loading branch information
bobthecow committed May 2, 2020
1 parent 8bb5c30 commit c3fc6a7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,13 @@ private function doNonInteractiveRun($rawOutput)

$this->beforeRun();
$this->loadIncludes();
$this->getInput(false);

// For non-interactive execution, read only from the input buffer or from piped input.
// Otherwise it'll try to readline and hang, waiting for user input with no indication of
// what's holding things up.
if (!empty($this->inputBuffer) || $this->config->inputIsPiped()) {
$this->getInput(false);
}

if ($this->hasCode()) {
$ret = $this->execute($this->flushCode());
Expand Down

0 comments on commit c3fc6a7

Please sign in to comment.