pexpect: Consume color sequences in expect_prompt

We typically use TERM=dumb, but in some cases we need actual cursor
and color stuff.
This commit is contained in:
Fabian Homborg 2020-06-13 19:18:12 +02:00
parent 51e3258dbe
commit 5478d979a0

View File

@ -31,9 +31,13 @@ def get_prompt_re(counter):
""" Return a regular expression for matching a with a given prompt counter. """
return re.compile(
r"""(?:\r\n?|^) # beginning of line
(?:\x1b[\d\[KB(m]*)* # optional colors
(?:\[.\]\ )? # optional vi mode prompt
"""
+ (r"prompt\ %d>" % counter), # prompt with counter
+ (r"prompt\ %d>" % counter) # prompt with counter
+ r"""
(?:\x1b[\d\[KB(m]*)* # optional colors
""",
re.VERBOSE,
)