File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 11<?php
22
3+ // this example prints anything you type on STDIN to STDOUT
4+ // control codes will be given as their hex values for easier inspection.
5+ // also try this out with special keys on your keyboard:
6+ // $ php stdin-codes.php
7+ //
8+ // you can also pipe the output of other commands into this to see any control
9+ // codes like this:
10+ // $ phpunit --color=always | php stdin-codes.php
11+
312use React \Stream \Stream ;
413use React \EventLoop \Factory ;
514use Clue \React \Term \ControlCodeParser ;
817
918$ loop = Factory::create ();
1019
11- // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
12- shell_exec ('stty -icanon -echo ' );
20+ if (function_exists ('posix_isatty ' ) && posix_isatty (STDIN )) {
21+ // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
22+ shell_exec ('stty -icanon -echo ' );
23+ }
1324
1425// process control codes from STDIN
1526$ stdin = new Stream (STDIN , $ loop );
You can’t perform that action at this time.
0 commit comments