mirror of https://github.com/MidnightCommander/mc
commandline: strip_escape: strip xterm OSC commands in $PS1
Correctly deal with prompts like (appear in debian/ubuntu): PS1='\[\e]0;\u@\h: \w\a\]\u@\h:\w\$' PS1='\[\e]0;\u@\h: \w\e\\\]\u@\h:\w\$' Based on patch provided provided by Sergey Nizovtsev https://bugs.launchpad.net/ubuntu/+source/mc/+bug/330633 Signed-off-by: Sergei Trofimovich <st@anti-virus.by>
This commit is contained in:
parent
f7781c16e0
commit
9041e6c81f
28
src/util.c
28
src/util.c
|
@ -904,6 +904,34 @@ strip_ctrl_codes (char *s)
|
|||
if (*(++r) == '[') {
|
||||
/* strchr() matches trailing binary 0 */
|
||||
while (*(++r) && strchr ("0123456789;?", *r));
|
||||
} else
|
||||
if (*r == ']') {
|
||||
/*
|
||||
* Skip xterm's OSC (Operating System Command)
|
||||
* http://www.xfree86.org/current/ctlseqs.html
|
||||
* OSC P s ; P t ST
|
||||
* OSC P s ; P t BEL
|
||||
*/
|
||||
char * new_r = r;
|
||||
|
||||
for (; *new_r; ++new_r)
|
||||
{
|
||||
switch (*new_r)
|
||||
{
|
||||
/* BEL */
|
||||
case '\a':
|
||||
r = new_r;
|
||||
goto osc_out;
|
||||
case ESC_CHAR:
|
||||
/* ST */
|
||||
if (*(new_r + 1) == '\\')
|
||||
{
|
||||
r = new_r + 1;
|
||||
goto osc_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
osc_out:;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue