Re: php interactive shell without readline
| From: | Ivan Enderlin @ Hoa | Date: | Sun, 05 Aug 2012 09:50:25 +0000 |
| Subject: | Re: php interactive shell without readline | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62046@lists.php.net to get a copy of this message | ||
Hello,
This project is interesting but it is also possible to do it only with PHP.
As a proof of concept, I would like to share some links with you. First one: http://hg.hoa-project.net/Central/file/tip/Library/Console/Readline/Readline.php, which is highly hackable: we can add mappings (esc, ctrl, abc…), history (when pressing key up and key down) and it works as an infinite automaton based on the STATE_* constants. And thanks to PHP and its static:: keyword, we can overload states, e.g.: http://hg.hoa-project.net/Central/file/tip/Library/Console/Readline/Password.php. Hop, password is hidden :-).
This library has some limitations: it does not support multibytes (Unicode) and has an unlimited history (which can cause memory errors), but it is a (advanced-)POC. It works on Unix-based system, actually STTY-based shells, and has a pretty simple fallback for DOS. It does not require PHP to be compiled --with-readline, it uses stty options instead. And finally, it uses around 850 lines of codes (with comments + licences).
Best regards :-).
On 04/08/12 21:50, Andrew Faulds wrote:
Well, I saw it, and I say for a ~600 line library, why not? Heck, we could maybe reimplement the readline extension with it. On 04/08/12 20:49, Ferenc Kovacs wrote:-- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/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). 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?