From 5478d979a0ad7897dd5d17d485b89daa371f3d36 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 13 Jun 2020 19:18:12 +0200 Subject: [PATCH] pexpect: Consume color sequences in expect_prompt We typically use TERM=dumb, but in some cases we need actual cursor and color stuff. --- build_tools/pexpect_helper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build_tools/pexpect_helper.py b/build_tools/pexpect_helper.py index 48dd289b2..982c6fb9b 100644 --- a/build_tools/pexpect_helper.py +++ b/build_tools/pexpect_helper.py @@ -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, )