php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65714 PHP cli forces the tty to cooked mode
Submitted: 2013-09-19 15:34 UTC Modified: 2013-11-15 08:38 UTC
From: addw at phcomp dot co dot uk Assigned: remi
Status: Closed Package: CGI/CLI related
PHP Version: 5.5.4 OS: Linux/Unix
Private report: No CVE-ID:
 [2013-09-19 15:34 UTC] addw at phcomp dot co dot uk
Description:
------------
I am running a PHP script at the command line and piping the output through less:

    ./myScript | less

Since less is an interactive program it puts the terminal into 'raw' mode so
that it can read characters one at a time. However, when I do the above I find
that the commands that I type to less are echoed back to me and not acted on
until I type <RETURN>. This is not as it should be.

The sript is not doing anything clever, just generating 100 lines:
    for($i = 0; $i < 100; $i++)
        echo "i=$i\n";

This has been discussed on the Internals mail list, the thread starts here:

http://marc.info/?l=php-internals&m=137915919531612&w=2


Test script:
---------------
I suggest a solution here:

http://marc.info/?l=php-internals&m=137951748702534&w=2




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-15 08:38 UTC] remi@php.net
-Assigned To: +Assigned To: remi
 [2013-11-15 08:43 UTC] remi@php.net
A simple solution is to not call using_history() which seems not required with libedit (haven't test with readline).

Without this call, readline_* functions still work as expected.

A explicit call to readline_read_history still required to keep history across runs.
 [2013-11-15 08:53 UTC] remi@php.net
Automatic comment on behalf of remi
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b8d88bf2c588dcaec185468da8db306cd7e6ab8d
Log: Fix Bug #65714 	PHP cli forces the tty to cooked mode
 [2013-11-15 08:53 UTC] remi@php.net
-Status: Assigned +Status: Closed
 [2013-11-15 10:08 UTC] ab@php.net
Automatic comment on behalf of remi
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b8d88bf2c588dcaec185468da8db306cd7e6ab8d
Log: Fix Bug #65714 	PHP cli forces the tty to cooked mode
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of remi
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b8d88bf2c588dcaec185468da8db306cd7e6ab8d
Log: Fix Bug #65714 	PHP cli forces the tty to cooked mode
 [2014-01-20 07:41 UTC] remi@php.net
Automatic comment on behalf of remi
Revision: http://git.php.net/?p=php-src.git;a=commit;h=31d67bd35362c1ab570caccedfec3e24257b55c5
Log: Fixed Bug #66412 readline_clear_history() with libedit causes segfault after #65714
 [2014-01-20 17:07 UTC] ab@php.net
Automatic comment on behalf of remi
Revision: http://git.php.net/?p=php-src.git;a=commit;h=31d67bd35362c1ab570caccedfec3e24257b55c5
Log: Fixed Bug #66412 readline_clear_history() with libedit causes segfault after #65714
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 19:01:53 2014 UTC