From: David Gibson <david(a)gibson.dropbear.id.au> pane_parse() attempts to grab the output from the last command issued into a tmux pane. It strips out control characters using tr, which in particular includes the final \r\n. However, this won't fully strip out terminal escape sequences. In particular this breaks if the shell in the pane is bash, with enable-bracketed-paste enabled in readline. That issues terminal sequences to enable and disable bracketed paste mode around every shell prompt. We can work around this because these escapes are followed by a \r (CR). More generally, it seems reasonable to assume that any terminal shenanigans followed by a CR, but not an LF is supposed to be hidden. So, use sed to strip everything before the second last CR. We still need the tr to remove the final \r\n from the string (sed processes a line at a time, and doesn't consider the CRLF part of the buffer it's processing). Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> [sbrivio: modify regexp to keep foo\r\r\n unchanged, by matching on at least one CR and a non-CR afterwards: that's the usual output pattern for bash on Debian 8 and Debian 9] Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- test/lib/term | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/term b/test/lib/term index 7dd9826..0093f90 100755 --- a/test/lib/term +++ b/test/lib/term @@ -221,7 +221,7 @@ pane_wait() { pane_parse() { __pane_lc="$(echo "${1}" | tr [A-Z] [a-z])" - __buf="$(tail -n2 ${LOGDIR}/pane_${__pane_lc}.log | head -n1 | tr -d -c [:print:])" + __buf="$(tail -n2 ${LOGDIR}/pane_${__pane_lc}.log | head -n1 | sed 's/^[^\r]*\r\([^\r]\)/\1/' | tr -d '\r\n')" [ "# $(eval printf '%s' \"\$${1}_LAST_CMD\")" != "${__buf}" ] && \ [ "$ $(eval printf '%s' \"\$${1}_LAST_CMD\")" != "${__buf}" ] && -- 2.35.1