[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unwanted `^A' and `^B' characters in bash prompt.
From: |
Lute Kamstra |
Subject: |
Re: Unwanted `^A' and `^B' characters in bash prompt. |
Date: |
Mon, 02 Jun 2003 17:08:11 +0200 |
User-agent: |
Gnus/5.1001 (Gnus v5.10.1) Emacs/21.3 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> This, however, does not solve the problem for users of current
> versions of bash (including me :-( ). So I wrote a small
> function that removes the unwanted `^A' and `^B' characters from
> the bash prompt. Shall I put this function in etc/PROBLEMS as
> shown in the patch below?
>
> Is there a reasonable way to install this code in comint.el or
> shell.el that won't do any harm to users in other situations? All
> else being equal, it would be better to DTRT automatically than to
> make the user go to an effort to compensate.
The patch below should do the job.
I'll commit it in a few days if nobody objects.
Lute.
*** lisp/shell.el.~1.118.~ 2003-01-31 16:18:17.000000000 +0100
--- lisp/shell.el 2003-06-02 16:12:32.000000000 +0200
***************
*** 454,462 ****
(setq shell-dirstack-query
(cond ((string-equal shell "sh") "pwd")
((string-equal shell "ksh") "echo $PWD ~-")
! (t "dirs"))))
(comint-read-input-ring t)))
(defun shell-write-history-on-exit (process event)
"Called when the shell process is stopped.
--- 454,483 ----
(setq shell-dirstack-query
(cond ((string-equal shell "sh") "pwd")
((string-equal shell "ksh") "echo $PWD ~-")
! (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 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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Unwanted `^A' and `^B' characters in bash prompt.,
Lute Kamstra <=