Bug #72312 [NEW]: cli.prompt with \e colours breaks interactive shell wrapping

From: Date: Thu, 02 Jun 2016 03:29:49 +0000
Subject: Bug #72312 [NEW]: cli.prompt with \e colours breaks interactive shell wrapping
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201392@lists.php.net to get a copy of this message
From:             christopher dot jf dot hopper at gmail dot com
Operating system: Ubuntu 14.04.4 LTS
PHP version:      7.0.7
Package:          CGI/CLI related
Bug Type:         Bug
Bug description:cli.prompt with \e colours breaks interactive shell wrapping

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 bug report at https://bugs.php.net/bug.php?id=72312&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72312&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72312&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72312&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72312&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72312&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72312&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72312&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72312&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72312&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72312&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72312&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72312&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72312&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72312&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72312&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72312&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72312&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72312&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72312&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72312&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#201392) next »