Regression - extra terminal escape codes emitted

2020-11-02 Thread Joe Nahmias
Hello bash team,

I've noticed a regression in one of my test suites for a program using the
python pexpect library, after upgrading from 5.0.3(1)-release to
5.1.0(1)-rc1. Here's a minimal test case (in python) I've created:

#!/usr/bin/python3

import os
import pexpect

ps1 = "MYspECIalpROmpt: "
env = {
"HOME": os.environ["HOME"],
"LANG": "en_US.UTF-8",
"LOGNAME": os.environ["LOGNAME"],
"PS1": ps1,
"PATH": "/usr/local/bin:/usr/bin:/bin",
"TERM": "dumb",
"USER": os.environ["USER"],
}
expects = [pexpect.TIMEOUT, "(\r\n)?" + ps1]

child = pexpect.spawn("bash --norc", env=env, echo=False)
pos = child.expect(expects, timeout=1)
child.sendline('echo $BASH_VERSION')
pos = child.expect(expects, timeout=1)
if pos:
print(f'Got BASH_VERSION="{child.before.decode("utf-8")}".')
else:
print("expect() timed-out!")
print(f"Debug info:\n{str(child)}")

child.sendline("exit")
child.close()
# EOF


When running on a machine with bash 5.1.0(1)-rc1 installed, I get:
$ ./test.py
5.1.0(1)-rc1SION="
".
Debug info:

command: /usr/bin/bash
args: ['/usr/bin/bash', '--norc']
buffer (last 100 chars): b''
before (last 100 chars): b'\x1b[?2004l\r5.1.0(1)-rc1\r\n\x1b[?2004h'
after: b'MYspECIalpROmpt: '
match: 
match_index: 1
exitstatus: None
flag_eof: False
pid: 2018364
child_fd: 5
closed: False
timeout: 30
delimiter: 
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1


After I downgrade to bash 5.0.18(1)-release, I get:
$ ./test.py
Got BASH_VERSION="5.0.18(1)-release".
Debug info:

command: /usr/bin/bash
args: ['/usr/bin/bash', '--norc']
buffer (last 100 chars): b''
before (last 100 chars): b'5.0.18(1)-release'
after: b'\r\nMYspECIalpROmpt: '
match: 
match_index: 1
exitstatus: None
flag_eof: False
pid: 2019518
child_fd: 5
closed: False
timeout: 30
delimiter: 
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1


Please let me know if you need any additional information.
--Joe



Re: Regression - extra terminal escape codes emitted

2020-11-02 Thread Chet Ramey
On 11/2/20 12:29 PM, Joe Nahmias wrote:
> Hello bash team,
> 
> I've noticed a regression in one of my test suites for a program using the
> python pexpect library, after upgrading from 5.0.3(1)-release to
> 5.1.0(1)-rc1. 

Thanks for the report. These are the escape sequences that enable and
disable the terminal's bracketed paste mode, which is enabled by default.
Bash-5.1-rc2 will inhibit these sequences if the terminal name is "dumb"
or unknown.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/