Subject: Re: bug#12792: 24.2.50; shell-mode renders all its output in a yellow face

From: Dima Kogan <[email-masked]>
Date: Mon, 5 Nov 2012 15:57:11 -0800

> On Mon, 05 Nov 2012 16:00:34 +0100
> Wolfgang Jenkner <[email-masked]> wrote:
>
> On Mon, Nov 05 2012, Dima Kogan wrote:
> 
> > The output (with all the 'escape' characters replaced with '\e' to
> > make sure the email handlers don't get confused):
> >
> >
> > \e[31mdima@shorty\e[39m:\e[33m~\e[39m$ 
> > \e[31mdima@shorty\e[39m:\e[33m~\e[39m$ 
> > \e[31mdima@shorty\e[39m:\e[33m~\e[39m$ seq 5
> > 1
> > 2
> > 3
> > 4
> > 5
> > \e[31mdima@shorty\e[39m:\e[33m~\e[39m$ ls --color=auto -ld .emacs.d
> > drwxr-xr-x 6 dima dima 4096 Nov  3 15:31 \e[0m\e[01;34m.emacs.d\e[0m
> > \e[31mdima@shorty\e[39m:\e[33m~\e[39m$ seq 5
> > 1
> > 2
> > 3
> > 4
> > 5
> > \e[31mdima@shorty\e[39m:\e[33m~\e[39m$ 
> >
> >
> [...]
> > If I evaluate your defun also, I get everything red (nil face also)
> > until the ".emacs.d". The ".emacs.d" is blue, as it should be. From
> > that point on, all the plain output is black and all the prompts
> > are blue. This is correct, except the prompts still shouldn't be
> > all blue.
> 
> Thanks for the precise recipe.  I installed zsh 5.0.0 from ports in
> FreeBSD 9 and tried it, but I can't reproduce the bogus red colouring
> (with the rewritten ansi-color-apply-sequence).
> 
> So I would like to ask you to do some more investigation:
> 
> As usual, load ansi-color and then eval the new definition of
> ansi-color-apply-sequence.
> 
> Then
> 
> M-x trace-function-background <return> ansi-color-apply-sequence
> <return> <return> M-x trace-function-background <return>
> comint-output-filter <return> <return>
> 
> M-x shell and type in the same shell commands as above.
> 
> M-x untrace-all
> 
> Then please attach the content of "*trace-output*" to your reply.
> 
> Wolfgang
> 
> 
> 
> 

Hi Wolfgang. I just ran those tests.

Previously, I would do M-x shell, and then evaluate the new defun; this produced
the results I described earlier.

You just asked for a different order: load ansi-color, comint, THEN eval defun,
THEN M-x shell. That produces different colored results: everything looks
correct except the prompt is all blue all the time. Nothing has nil face. Is
this the expected behavior with that defun, or is the prompt supposed to look
right also?

The trace output follows. Note that once again I replaced all escape characters with '\e'.

======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 18 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 36 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 54 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 72 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 90 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 108 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 126 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="1
2
3
4
"
1 <- comint-output-filter: #<marker (moves after insertion) at 140 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="5
\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 159 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="drwxr-xr-x 4 dima dima 4096 Nov  5 00:33 \e[0m\e[01;34m/home/dima/.emacs.d\e[0m
"
| 2 -> ansi-color-apply-sequence: escape-sequence=#("0m" 0 2 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("01;34m" 0 6 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (34 1)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("0m" 0 2 (fontified nil)) codes=(34 1)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 251 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 268 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 286 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 304 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="1
2
3
4
"
1 <- comint-output-filter: #<marker (moves after insertion) at 318 in *shell*>
======================================================================
1 -> comint-output-filter: process=#<process shell> string="5
\e[32mdima@fatty\e[39m:\e[33m/tmp\e[39m$ "
| 2 -> ansi-color-apply-sequence: escape-sequence=#("32m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (32)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(32)
| 2 <- ansi-color-apply-sequence: nil
| 2 -> ansi-color-apply-sequence: escape-sequence=#("33m" 0 3 (fontified nil)) codes=nil
| 2 <- ansi-color-apply-sequence: (33)
| 2 -> ansi-color-apply-sequence: escape-sequence=#("39m" 0 3 (fontified nil)) codes=(33)
| 2 <- ansi-color-apply-sequence: nil
1 <- comint-output-filter: #<marker (moves after insertion) at 337 in *shell*>