From 59be5828de98814b8aa32718bf2b6196db085db1 Mon Sep 17 00:00:00 2001
From: Eli Zaretskii <eliz@gnu.org>
Date: Fri, 16 Dec 2005 12:16:35 +0000
Subject: [PATCH] (term-emulate-terminal): Let
 term-handle-ansi-terminal-messages override what Bash says about its current
 directory.

---
 lisp/term.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/term.el b/lisp/term.el
index 14d4fb9a5ab..62728f45a08 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -2687,13 +2687,17 @@ See `term-prompt-regexp'."
 	   (buffer-undo-list t)
 	   (selected (selected-window))
 	   last-win
+           handled-ansi-message
 	   (str-length (length str)))
       (save-selected-window
 
 	;; Let's handle the messages. -mm
 
-	(setq str (term-handle-ansi-terminal-messages str))
-	(setq str-length (length str))
+        (let* ((newstr (term-handle-ansi-terminal-messages str)))
+          (if (not (eq str newstr))
+              (setq handled-ansi-message t
+                    str newstr)))
+        (setq str-length (length str))
 
 	(if (marker-buffer term-pending-delete-marker)
 	    (progn
@@ -2849,7 +2853,8 @@ See `term-prompt-regexp'."
 			 ((eq char ?\017))     ; Shift In - ignored
 			 ((eq char ?\^G) ;; (terminfo: bel)
 			  (beep t))
-			 ((eq char ?\032)
+			 ((and (eq char ?\032)
+                               (not handled-ansi-message))
 			  (let ((end (string-match "\r?$" str i)))
 			    (if end
 				(funcall term-command-hook
-- 
2.39.5