]> code.delx.au - gnu-emacs/commitdiff
(shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
authorLute Kamstra <lute@gnu.org>
Thu, 5 Jun 2003 12:02:09 +0000 (12:02 +0000)
committerLute Kamstra <lute@gnu.org>
Thu, 5 Jun 2003 12:02:09 +0000 (12:02 +0000)
`comint-output-filter-functions' when bash is used as the inferior
shell.
(shell-filter-ctrl-a-ctrl-b): New function.

lisp/ChangeLog
lisp/shell.el

index 6db45b28c428a80e3e65726e7049e44967010356..662c77d74f029b5e19dde9b26c15110a1b24c182 100644 (file)
@@ -1,3 +1,10 @@
+2003-06-05  Lute Kamstra  <Lute.Kamstra@cwi.nl>
+
+       * shell.el (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
+       `comint-output-filter-functions' when bash is used as the inferior
+       shell.
+       (shell-filter-ctrl-a-ctrl-b): New function.
+
 2003-06-05  Dave Love  <fx@gnu.org>
 
        * vc-hooks.el (vc-make-backup-files): Add :group backup.
index 77ad7f2808c6153c84bb5d75680ed41f3a6fee53..154c4ff46eb9cf3d3e418891d8bec3b24e4d7ffb 100644 (file)
@@ -454,9 +454,31 @@ buffer."
       (setq shell-dirstack-query
            (cond ((string-equal shell "sh") "pwd")
                  ((string-equal shell "ksh") "echo $PWD ~-")
-                 (t "dirs"))))
+                 (t "dirs")))
+      ;; Bypass a bug in certain versions of bash.
+      (when (string-equal shell "bash")
+        (add-hook 'comint-output-filter-functions
+                  'shell-filter-ctrl-a-ctrl-b nil t)))
     (comint-read-input-ring t)))
 
+(defun shell-filter-ctrl-a-ctrl-b (string)
+  "Remove `^A' and `^B' characters from comint output.
+
+Bash uses these characters as internal quoting characters in its
+prompt.  Due to a bug in some bash versions (including 2.03,
+2.04, and 2.05b), they may erroneously show up when bash is
+started with the `--noediting' option and Select Graphic
+Rendition (SGR) control sequences (formerly known as ANSI escape
+sequences) are used to color the prompt.
+
+This function can be put on `comint-output-filter-functions'.
+The argument STRING is ignored."
+  (let ((pmark (process-mark (get-buffer-process (current-buffer)))))
+    (save-excursion
+      (goto-char (or comint-last-output-start (point-min)))
+      (while (re-search-forward "[\C-a\C-b]" pmark t)
+        (replace-match "")))))
+
 (defun shell-write-history-on-exit (process event)
   "Called when the shell process is stopped.