Skip to content

Commit

Permalink
Disable baacketed-paste mode in bash 5.1 and newer (issue pexpect#669)
Browse files Browse the repository at this point in the history
The bash versions starting with 5.1 have bracketed paste mode enabled
by default, leading to test failures in replwrap.bash(), e.g.:

self = <tests.test_replwrap.REPLWrapTestCase testMethod=test_multiline>

    def test_multiline(self):
        bash = replwrap.bash()
        res = bash.run_command("echo '1 2\n3 4'")
>       self.assertEqual(res.strip().splitlines(), ['1 2', '3 4'])
E       AssertionError: Lists differ: ['\x1b[?2004l', '\x1b[?2004h\x1b[?2004l',
'1 2', '3 4', '\x1b[?2004h'] != ['1 2', '3 4']
E
E       First differing element 0:
E       '\x1b[?2004l'
E       '1 2'
E
E       First list contains 3 additional elements.
E       First extra element 2:
E       '1 2'
E
E       - ['\x1b[?2004l', '\x1b[?2004h\x1b[?2004l', '1 2', '3 4', '\x1b[?2004h']
E       + ['1 2', '3 4']

With bracketed test mode disabled, the tests that were affected by the
inserted escape sequences succeed.
  • Loading branch information
stesser committed Sep 22, 2021
1 parent b717990 commit 242c367
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pexpect/bashrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ PS1="$"

# Unset PROMPT_COMMAND, so that it can't change PS1 to something unexpected.
unset PROMPT_COMMAND

bind 'set enable-bracketed-paste off'

0 comments on commit 242c367

Please sign in to comment.