Bug 253401

Summary: mc on root konsole show me a "B" on the command line
Product: [openSUSE] openSUSE 10.3 Reporter: Chema Ollés <jmolles>
Component: OtherAssignee: Vladimir Nadvornik <nadvornik>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: werner
Version: Alpha 1plus   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: photo with my mc

Description Chema Ollés 2007-03-10 19:38:49 UTC
Hi all
I update the system this afternoon I after I see when run mc from konsole with root privileges there are a "B" on the command line of mc and I can't delete them.
When exit from mc the "B" disappears. 
It's happens the same when run mc from xterm and like root.
Run mc from other user there are no effect.
Regards
Comment 1 Matej Horvath 2007-03-12 13:23:26 UTC
What version of mc are you running? Could you please attach a screenshot?
Comment 2 Chema Ollés 2007-03-12 22:17:45 UTC
Created attachment 123938 [details]
photo with my mc

Hi,this is the version I have
mc-4.6.1-73
Comment 3 Vladimir Nadvornik 2007-03-13 12:13:21 UTC
What is the output of 'locale' command in the same xterm?
Does it happen with 'export LANG=C' too?

Comment 4 Chema Ollés 2007-03-13 15:54:51 UTC
Hi
locale on konsole:
linux:~ # locale
LANG=es_ES.UTF-8
LC_CTYPE="es_ES.UTF-8"
LC_NUMERIC="es_ES.UTF-8"
LC_TIME="es_ES.UTF-8"
LC_COLLATE="es_ES.UTF-8"
LC_MONETARY="es_ES.UTF-8"
LC_MESSAGES="es_ES.UTF-8"
LC_PAPER="es_ES.UTF-8"
LC_NAME="es_ES.UTF-8"
LC_ADDRESS="es_ES.UTF-8"
LC_TELEPHONE="es_ES.UTF-8"
LC_MEASUREMENT="es_ES.UTF-8"
LC_IDENTIFICATION="es_ES.UTF-8"
LC_ALL=
after export LANG="C";mc
The same effect
Regards

Comment 5 Magnus Boman 2007-04-04 11:18:33 UTC
*** Bug 260714 has been marked as a duplicate of this bug. ***
Comment 6 Dr. Werner Fink 2007-04-04 12:44:18 UTC
It seems that mc can not handle escape secquences within the PS1 prompt.
Please note that I'll not change this prompt (see bug #144620) because
on a standard prompt it works flawless.
Comment 7 Pavol Rusnak 2007-04-04 12:49:36 UTC
I have following line in my /root/.bashrc :

export PS1='\[\033[1;37m\][\[\033[1;31m\]\u\[\033[0m\]@\h\[\033[0m\] \[\033[1;34m\]\w\[\033[1;37m\]]\[\033[0m\] '

and this prompt works both in shell and in mc.
Comment 8 Dr. Werner Fink 2007-04-04 13:51:45 UTC
Not acceptable because you never know if the escape sequences will
cause trouble without using tput, therefore I prefere

  if test "$UID" -eq 0 -a -t && type -p tput > /dev/null 2>&1 ; then
     _bred="$(tput bold 2> /dev/null; tput setaf 1 2> /dev/null)"
     _sgr0="$(tput sgr0 2> /dev/null)"
     PS1="\[$_bred\]$PS1\[$_sgr0\]"
     unset _bred _sgr0
  fi

resulting e.g. for a real xterm to

  \[\033[1m\033[31m\]\h:\W \$ \[\033(B\033[m\]

the question rises why this results in `B' for your mc.  Which
terminal type is used by mc?  Beside this I've started mc as
root on magellan and it works flawless, e.g. no colored prompt
and no `B'.   IMHO this `B' is related to the sgr0 sequences
of TERM=xterm, nevertheless this is send to the terminal and
not to the prompt.  And as long the terminal can handle its
sequences you never will see this.
Comment 9 Vladimir Nadvornik 2007-04-18 13:13:56 UTC
mc filters the prompt with this function:
==========
/* Remove all control sequences from the argument string.  We define
 * "control sequence", in a sort of pidgin BNF, as follows:
 *
 * control-seq = Esc non-'['
 *             | Esc '[' (0 or more digits or ';' or '?') (any other char)
 *
 * This scheme works for all the terminals described in my termcap /
 * terminfo databases, except the Hewlett-Packard 70092 and some Wyse
 * terminals.  If I hear from a single person who uses such a terminal
 * with MC, I'll be glad to add support for it.  (Dugan)
 * Non-printable characters are also removed.
 */

char *strip_ctrl_codes (char *s)
===========

It apparently needs to be extended. Werner, can please suggest, what needs to be added? Is there any documentation available?
Comment 10 Dr. Werner Fink 2007-04-18 13:26:54 UTC
Simply use
   infocmp -T xterm -1 | less
to see the sgr0 terminfo item. IMHO the character ( hast to
accepted beside ESC ; ? [ 0-9  and a-zA-Z.  Sometimes also the
characters ! and > are also used.
Comment 11 Pavol Rusnak 2007-07-12 15:51:27 UTC
*** Bug 291051 has been marked as a duplicate of this bug. ***
Comment 12 Vladimir Nadvornik 2007-07-17 15:36:26 UTC
fixed: mc can now detect the \033(B sequence