Bug #72312 [Opn]: cli.prompt with \e colours breaks interactive shell wrapping
Edit report at https://bugs.php.net/bug.php?id=72312&edit=1
ID: 72312
User updated by: christopher dot jf dot hopper at gmail dot com
Reported by: christopher dot jf dot hopper at gmail dot com
Summary: cli.prompt with \e colours breaks interactive shell
wrapping
Status: Open
Type: Bug
Package: CGI/CLI related
Operating System: Ubuntu 14.04.4 LTS
PHP Version: 7.0.7
Block user comment: N
Private report: N
New Comment:
Test Script:
------------
Simplified test script.
// Execute in Interactive Shell with php -a
ini_set('cli.prompt','\e[032m\v \e[031m\b \e[34m\> \e[0m');
print ini_get('cli.prompt');
echo "This is a long line that should wrap and it does when cli.prompt contains no
non-printable characters";
Previous Comments:
------------------------------------------------------------------------
[2016-06-02 03:29:46] christopher dot jf dot hopper at gmail dot com
Description:
------------
When adding colours to cli.prompt with \e these non-printable characters cause incorrect wrapping
behaviour by the interactive shell.
Steps to Reproduce
------------------
1. Open a terminal window.
2. Ensure the terminal window is not maximized and reduce its width to around 80 columns.
3. Run the php interactive shell with php -a
4. Type a single, long line of code that wraps to the next line.
5. Add colors to the cli.prompt with \e as per http://php.net/manual/en/features.commandline.interactive.php#example-430
6. Try typing another long line of code that should wrap to the next line.
Configure
---------
This is my PHP 7 build configuration:
./configure \
--prefix=/usr/local \
--mandir=/usr/local/man \
--with-config-file-path=/usr/local/etc \
--with-config-file-scan-dir=/usr/local/etc/php.d \
--disable-cgi \
--enable-bcmath \
--enable-cli \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-phar \
--enable-shared \
--enable-zip \
--with-bz2 \
--with-curl \
--with-iconv \
--with-mcrypt \
--with-openssl \
--with-pear \
--with-readline \
--with-zlib
Test script:
---------------
// Execute in Interactive Shell with php -a
ini_set('cli.prompt','\e[032m\v \e[031m\b \e[34m\> \e[0m');
print ini_get('cli.prompt');
echo "This is a long line that should wrap and it does when cli.prompt contains no
non-printable characters";
ini_restore('cli.prompt');
ini_get('cli.prompt');
echo "This is a long line that should wrap and it does when cli.prompt contains no
non-printable characters";
Expected result:
----------------
Last line typed wraps to newline. Terminal looks like this:
7.0.6 php > echo "This is a long line that should wrap and it does when cli.prompt contains
no non-printable characters";
This is a long line that should wrap but it does not when the cli.prompt contains non-printable
characters
Actual result:
--------------
last line typed wraps on itself. Terminal looks like this:
t does not when the cli.prompt contains non-printable characters";
This is a long line that should wrap but it does not when the cli.prompt contains non-printable
characters
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72312&edit=1
Thread (2 messages)