Skip to content

Commit 5da4d99

Browse files
authored
Merge pull request #78 from clue-labs/resetty
Fix restoring TTY mode when ext-readline is not in use
2 parents 1ddc137 + f91ddf5 commit 5da4d99

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/Stdio.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ private function createStdin(LoopInterface $loop)
291291
}
292292

293293
if ($this->isTty()) {
294-
$this->originalTtyMode = shell_exec('stty -g');
294+
$this->originalTtyMode = rtrim(shell_exec('stty -g'), PHP_EOL);
295295

296296
// Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
297297
shell_exec('stty -icanon -echo');

tests/FunctionalExampleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ public function testStubCanCloseStdoutAndIsNotWritable()
8787
$this->assertEquals('', $output);
8888
}
8989

90+
public function testStubCanEndWithoutOutput()
91+
{
92+
$output = $this->execExample('php ../tests/stub/04-end.php');
93+
94+
$this->assertEquals('', $output);
95+
}
96+
97+
public function testStubCanEndWithoutExtensions()
98+
{
99+
$output = $this->execExample('php -n ../tests/stub/04-end.php');
100+
101+
$this->assertEquals('', $output);
102+
}
103+
90104
public function testPeriodicExampleViaInteractiveModeQuitsImmediately()
91105
{
92106
if (defined('HHVM_VERSION')) {

tests/stub/04-end.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
use Clue\React\Stdio\Stdio;
4+
5+
require __DIR__ . '/../../vendor/autoload.php';
6+
7+
$loop = React\EventLoop\Factory::create();
8+
9+
$stdio = new Stdio($loop);
10+
$stdio->end();
11+
12+
$loop->run();

0 commit comments

Comments
 (0)