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: -
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: Open Package: Readline related
PHP Version: 7.1.4 OS: OSX
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 00:01:24 2019 UTC