Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62058 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84515 invoked from network); 5 Aug 2012 23:39:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Aug 2012 23:39:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.134 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.134 oxmail.registrar-servers.com Linux 2.6 Received: from [64.22.89.134] ([64.22.89.134:41047] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/F2-03102-0340F105 for ; Sun, 05 Aug 2012 19:39:28 -0400 Received: from [192.168.0.200] (5ad4bfa0.bb.sky.com [90.212.191.160]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 192D13E8004; Sun, 5 Aug 2012 19:39:23 -0400 (EDT) Message-ID: <501F0412.2060003@ajf.me> Date: Mon, 06 Aug 2012 00:38:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Ferenc Kovacs CC: =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8dGVy?= , PHP Internals References: <1344205126.1440.1086.camel@guybrush> <501F0047.9080005@ajf.me> In-Reply-To: Content-Type: multipart/alternative; boundary="------------060303020604020900090306" Subject: Re: [PHP-DEV] php interactive shell without readline From: ajf@ajf.me (Andrew Faulds) --------------060303020604020900090306 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 06/08/12 00:37, Ferenc Kovacs wrote: > > > On Mon, Aug 6, 2012 at 1:22 AM, Andrew Faulds > wrote: > > On 06/08/12 00:21, Ferenc Kovacs wrote: > > On Mon, Aug 6, 2012 at 12:18 AM, Johannes Schlüter > >wrote: > > On Sat, 2012-08-04 at 21:49 +0200, Ferenc Kovacs wrote: > > Hi, > > As most of you know, the current php interactive shell > is pretty much > useless without compiling php --with-readline, but for > the most users > > this > > the first impression what they experience (eg. using > the php interactive > shell without readline support). > > Note that for 5.4 I refactored the code so a shared > readline extension > is good enough by moving all shell related parts to > ext/readline. This > should reduce the pain for distribution package users > where typically > everything is shared. > > for the record that would be > https://bugs.php.net/bug.php?id=53878 and > http://git.php.net/?p=php-src.git;a=commit;h=6c734a6b4c9ecf90162cf53fcf5f89864ccabbde > right? > > There is an alternative readline replacement called > linenoise ( > https://github.com/antirez/linenoise/) written by the > author of Redis, > > and > > I would like to know, what do you think about using > that for the > interactive shell if php is built without readline > support. > It is really small/compact and it is under the two > clause BSD license so > > I > > think it would be a good candidate for bundling it in php. > What do you think about it? Is it something worth > looking into? > > There are two ways to do that: Either move the shell code > back to > sapi/cli or making ext/readline play nice with linenoise. > > I have to grasp the code a little bit better to answer that, > but from a > quick look I think that it was an improvement, that the > readline stuff was > moved out from there, so I think that we should keep that. > The linenoise would be always available and I think it would > be only a > couple of lines, so I think that it would be possible to put > it into > php_cli.c but as you mentioned we should make it such a way, > that even the > dynamically loaded readline has to be able to override it. > > > When using the first approach make sure that the user can > still pick > readline, as readline has features linenoise (currently) > hasn't, like > searching using Ctrl+r or configuration of the key > combinations. > > > agree, linenoise can't replace readline, so in general I think > that we > should only use it, if readline isn't available. > > > I'd > also like if readline can be built shared but still > overwrite the > built-in default. > > agree > > > Doing the second approach has the benefit that the lib can > be exported > to userland in the same run. While then there's little > benefit as it all > still depends on an extension ... > > (Actually there would be a third possibility - writing a > linenoise > extension which uses sapi/cli's hook but that requires > duplicating most > of the shell code and makes things more complicated, let#s > ignore > this ;-) ) > > What's your plan there? > > > to tell you the truth I'm just throwing around ideas and > waiting for > somebody with better understanding the actual implementation > to help me > out. ;) > > Well if linenoise() isn't that different, you could use #ifdefs to > make it use the correct lib at compile-time, no? > > > you mean putting the #ifdefs in ext/readline/readline_cli.c ? No, I mean moving code bact to sapi/cli/php_cli.c and using either readline or linenoise there as appropriate. > yeah that would be easy, but that would be both hackish and doesn't > solve anything, as that ext won't be loaded if readline isn't present. > this is why Johannes said, that we have to either move some code back > to sapi/cli/php_cli.c or integrate linenoise in such a way, that > dynamically loaded extensions could still replace/override it(else we > would lose Johannes work in 5.4 which made it possible to dynamically > load readline). > Johannes, please correct me if I'm factually wrong here. > > -- > Ferenc Kovács > @Tyr43l - http://tyrael.hu -- Andrew Faulds http://ajf.me/ --------------060303020604020900090306--