On 7/21/10 7:55 AM, Roman Rakus wrote:
> I can reproduce it.
Of course you can. You asked to see it.
> [rra...@dhcp-lab-170 tmp]$ mkdir '\E'
> [rra...@dhcp-lab-170 tmp]$ cd \\E/
> ]0;rra...@dhcp-lab-170:~/tmp/ra...@dhcp-lab-170 \E]$
> ]0;rra...@dhcp-lab-170:~/tmp/ra...@dhcp-lab-170 \E]$ set -x
> ++ echo -ne '\033]0;rra...@dhcp-lab-170:~/tmp/\E'
> [rra...@dhcp-lab-170 \E]$
> ]0;rra...@dhcp-lab-170:~/tmp/ra...@dhcp-lab-170 \E]$ echo $BASH_VERSION
> 4.1.7(1)-release
>
> Tried with gnome-terminal (gnome-terminal-2.30.1-1.fc13.x86_64) -
> reproducable
> with xterm (xterm-261-2.fc13.x86_64) - not reproducable
>
> echo $PS1
> [...@\h \W]\$
> echo $PROMPT_COMMAND
> echo -ne "\033]0;${us...@${hostname%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"
Consider what happens when you ask echo to expand escape sequences and
give it an argument containing arbitrary backslash-escapes, which it will
happily expand and mess up your terminal control sequence. The
uninterpreted portion will be output to the terminal.
I'm not sure why people don't use printf or $'' instead of echo.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/