bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New feature in bash 5.1/readline-8.1 rc1 breaks python-pexpect


From: Dr. Werner Fink
Subject: Re: New feature in bash 5.1/readline-8.1 rc1 breaks python-pexpect
Date: Fri, 16 Oct 2020 15:16:32 +0200

On 2020/10/16 09:03:53 -0400, Chet Ramey wrote:
> On 10/16/20 5:41 AM, Dr. Werner Fink wrote:
> > Hi,
> > 
> > after build rc1 of bash 5.1 as well as readline-8.1 I've set up test
> > staging process.  During build the package python-pexpect throws errors
> > in its test suite, e.g.
> > 
> > [  260s] self = <tests.test_async.AsyncTests 
> > testMethod=test_async_replwrap_multiline>
> > [  260s] 
> > [  260s]     def test_async_replwrap_multiline(self):
> > [  260s]         bash = replwrap.bash()
> > [  260s]         coro = bash.run_command("echo '1 2\n3 4'", async_=True)
> > [  260s]         res = run(coro)
> > [  260s] >       self.assertEqual(res.strip().splitlines(), ['1 2', '3 4'])
> > [  260s] E       AssertionError: Lists differ: ['\x1b[?2004l', 
> > '\x1b[?2004h\x1b[?2004l', '1 2', '3 4', '\x1b[?2004h'] != ['1 2', '3 4']
> > [  260s] E       
> > [  260s] E       First differing element 0:
> > [  260s] E       '\x1b[?2004l'
> > [  260s] E       '1 2'
> > [  260s] E       
> > [  260s] E       First list contains 3 additional elements.
> > [  260s] E       First extra element 2:
> > [  260s] E       '1 2'
> > [  260s] E       
> > [  260s] E       - ['\x1b[?2004l', '\x1b[?2004h\x1b[?2004l', '1 2', '3 4', 
> > '\x1b[?2004h']
> > [  260s] E       + ['1 2', '3 4']
> > 
> > I found this is caused by (_rl_)enable[-_]bracketed[-_]paste as the 
> > sequences
> > are defined in rlprivate.h
> > 
> >  #define BRACK_PASTE_INIT  "\033[?2004h"
> >  #define BRACK_PASTE_FINI  "\033[?2004l\r"
> > 
> > indeed it is a nice feature to see highlighted paste content on the 
> > interactive
> > command line, but why this interferes with tools like pexpect using bash in
> > interactive mode?
> 
> Yes, bracketed paste is currently enabled by default. I may change that by
> the time 5.1 is released.
> 
> I don't understand your question about tools like pexpect. If bracketed
> paste mode is on, it's on. How is readline supposed to know whether or not
> its stdin and stdout are connected to expect? How is the interactive shell
> run by pexpect different from one connected to a terminal?

I'm aware that if tools like pexpect uses a terminal emulator there is not
way to detect this.  If this feature can (in principal) not distinguish between
a real paste on a real command line and input from an (p)expect tools then it
should (IMHO) not be enabled.  Also a warning hint in the manual page could
help users before enabling this feature :)


Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]