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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
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: Mon Nov 04 11:01:29 2024 UTC