1 (edited by rbro 2019-03-14 15:29:06)

Topic: readline and printing color text

I am running CentOS 7 with PHP 7.2.  Not sure if this is configuration, but when I compile php manually with --with-readline, I can run:


and it prints the text "aaa" in red.

When I do it with the PHP 7.2 RPM's, it prints:


Comparing phpinfo(), my manual compile shows:

Readline Support => enabled
Readline library => 6.2

and the RPM shows:

Readline Support => enabled
Readline library => EditLine wrapper

Is there a way to use the RPM's and have the text print in color?

Thanks again for your help.


Re: readline and printing color text

Indeed, this doesn't seems to be supported by libedit.

Notice: libreadline is licensed under GPL version 3 which is NOT compatible with PHP license, so nobody is allowed to build and distribute packages using this library.
libedit is (sadly) the only supported and compatible alternative


P.S. FYI, there is a PR to totally drop libreadline support from PHP https://github.com/php/php-src/pull/3823

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 28 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: readline and printing color text

Thanks for your help.   I realized there is a easy workaround by doing:

echo "\033[0;31maaa\033[0m";
$a = readline();

The only other side effect I've seen with libedit so far is when I run "php -a", if I press the Home or End keys on my keyword, I get a tilde character ~.  I am running PuTTY on Windows and my TERM is currently set as xterm.  If I run "export TERM=linux" first, then it seems to fix it.