[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to show path with backslash '\' in it in the prompt?
From: |
Chet Ramey |
Subject: |
Re: How to show path with backslash '\' in it in the prompt? |
Date: |
Wed, 21 Jul 2010 08:58:23 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5 |
On 7/21/10 7:55 AM, Roman Rakus wrote:
> I can reproduce it.
Of course you can. You asked to see it.
> [rrakus@dhcp-lab-170 tmp]$ mkdir '\E'
> [rrakus@dhcp-lab-170 tmp]$ cd \\E/
> ]0;rrakus@dhcp-lab-170:~/tmp/rakus@dhcp-lab-170 \E]$
> ]0;rrakus@dhcp-lab-170:~/tmp/rakus@dhcp-lab-170 \E]$ set -x
> ++ echo -ne '\033]0;rrakus@dhcp-lab-170:~/tmp/\E'
> [rrakus@dhcp-lab-170 \E]$
> ]0;rrakus@dhcp-lab-170:~/tmp/rakus@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
> [\u@\h \W]\$
> echo $PROMPT_COMMAND
> echo -ne "\033]0;${USER}@${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 chet@case.edu http://cnswww.cns.cwru.edu/~chet/