|  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
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cornelius dot howl at gmail dot com
New email:
PHP Version: OS:


 [2017-05-11 16:11 UTC] cornelius dot howl at gmail dot com
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:


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


# echo foo | php readline.php

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


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]
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]
-Status: Open +Status: Verified
 [2021-08-27 13:23 UTC]
I can confirm Peter's findings (PHP-7.4).
 [2021-08-27 13:23 UTC]
-PHP Version: 7.1.4 +PHP Version: 7.4
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 11 23:01:29 2023 UTC