php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74574 readline duplicates the input by twice
Submitted: 2017-05-11 16:11 UTC Modified: 2021-08-27 13:23 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: cornelius dot howl at gmail dot com Assigned:
Status: Verified Package: Readline related
PHP Version: 7.4 OS: OSX
Private report: No CVE-ID: None
 [2017-05-11 16:11 UTC] cornelius dot howl at gmail dot com
Description:
------------
when piping string to the php executable, readline returns the duplicate input by twice.

Test script:
---------------
here is the simple script to reproduce this issue:

readline.php:

<?php echo readline(''); ?>

execute:

# echo foo | php readline.php


Expected result:
----------------
foo

Actual result:
--------------
foo
foo

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-11 16:15 UTC] yoanlin93 at gmail dot com
After further investigation, I found the first "foo" was output by php, and the other one was returned from readline().

This behavior is different from php 5.4~5.6
 [2019-02-10 21:17 UTC] petk@php.net
This happens due to different library usage.

When PHP is compiled with `./configure --with-libedit --without-readline` (using Libedit as a replacement for readline) only one foo is output.

When PHP is compiled with `--configure --with-readline` (using GNU readline library), two foo strings are output.
 [2021-08-27 13:23 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-08-27 13:23 UTC] cmb@php.net
I can confirm Peter's findings (PHP-7.4).
 [2021-08-27 13:23 UTC] cmb@php.net
-PHP Version: 7.1.4 +PHP Version: 7.4
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC