Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread Yongzhi Pan
On Tue, Mar 13, 2012 at 8:58 PM, Chet Ramey wrote: > On 3/12/12 12:22 AM, Yongzhi Pan wrote: > > Tested in GNU bash, version 3.00.16(1)-release and 4.1.2(1)-release. > > > > Upon login, home dir is displayed as tilde in PS1: > > pan@BJ-APN-2 ~$ echo $PS1 > > \[\033[35m\]\u@\h \w$ \[\033[0m\] > >

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread Eric Blake
On 03/13/2012 11:03 AM, dethrophes wrote: > > the missing "" in the case isn't redundant. It is too redundant; you only need "" after case if the parser would otherwise see two words before in. > case "$HOME" in >*[^/]* ) HOME=${HOME%${HOME##*[^/]}} ;; >/ | // ) ;; >*) HOME=/ ;; # //

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread dethrophes
Am 13.03.2012 18:13, schrieb Andreas Schwab: dethrophes writes: the missing "" in the case isn't redundant. i.e. case "$HOME" in The word is not subject to word splitting and filename expansion, so there is no need to quote. Andreas. Ok thanks for clarifying that.

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread Andreas Schwab
dethrophes writes: > the missing "" in the case isn't redundant. > i.e. case "$HOME" in The word is not subject to word splitting and filename expansion, so there is no need to quote. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 2

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread dethrophes
Am 13.03.2012 17:53, schrieb Eric Blake: On 03/13/2012 09:47 AM, dethrophes wrote: Am 13.03.2012 16:42, schrieb Eric Blake: On 03/13/2012 09:27 AM, Eric Blake wrote: Be aware that both approaches will misbehave if HOME is a root directory (/ or //), where you _don't_ want to strip trailing sla

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread Eric Blake
On 03/13/2012 09:47 AM, dethrophes wrote: > Am 13.03.2012 16:42, schrieb Eric Blake: >> On 03/13/2012 09:27 AM, Eric Blake wrote: >>> Be aware that both approaches will misbehave if HOME is a root directory >>> (/ or //), where you _don't_ want to strip trailing slashes. So you >>> really want: >>

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread dethrophes
Am 13.03.2012 16:42, schrieb Eric Blake: On 03/13/2012 09:27 AM, Eric Blake wrote: Be aware that both approaches will misbehave if HOME is a root directory (/ or //), where you _don't_ want to strip trailing slashes. So you really want: case $HOME in *[^/]* ) HOME=${HOME%${HOME##*[^/]}} ;;

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread Eric Blake
On 03/13/2012 09:27 AM, Eric Blake wrote: > Be aware that both approaches will misbehave if HOME is a root directory > (/ or //), where you _don't_ want to strip trailing slashes. So you > really want: > > case $HOME in > *[^/]* ) HOME=${HOME%${HOME##*[^/]}} ;; > esac Actually, shortening ///

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread dethrophes
Am 13.03.2012 16:27, schrieb Eric Blake: On 03/13/2012 09:18 AM, Roman Rakus wrote: as a workaround to your problem you could have something like this in your bashrc if shopt extglob&>/dev/null ; then HOME="${HOME/%+(\/)}" # strip all trailing forward slashes else while [ "${HOME}" !=

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread dethrophes
Am 13.03.2012 16:18, schrieb Roman Rakus: On 03/13/2012 04:08 PM, dethrophes wrote: Am 13.03.2012 06:04, schrieb Clark J. Wang: On Mon, Mar 12, 2012 at 12:22, Yongzhi Pan wrote: Tested in GNU bash, version 3.00.16(1)-release and 4.1.2(1)-release. Upon login, home dir is displayed as tilde

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread Eric Blake
On 03/13/2012 09:18 AM, Roman Rakus wrote: >> as a workaround to your problem you could have something like this in >> your bashrc >> if shopt extglob &>/dev/null ; then >> HOME="${HOME/%+(\/)}" # strip all trailing forward slashes >> else >>while [ "${HOME}" != "${HOME%\/}" ] ; do >>

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread Roman Rakus
On 03/13/2012 04:08 PM, dethrophes wrote: Am 13.03.2012 06:04, schrieb Clark J. Wang: On Mon, Mar 12, 2012 at 12:22, Yongzhi Pan wrote: Tested in GNU bash, version 3.00.16(1)-release and 4.1.2(1)-release. Upon login, home dir is displayed as tilde in PS1: pan@BJ-APN-2 ~$ echo $PS1 \[\033[35m

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread dethrophes
Am 13.03.2012 06:04, schrieb Clark J. Wang: On Mon, Mar 12, 2012 at 12:22, Yongzhi Pan wrote: Tested in GNU bash, version 3.00.16(1)-release and 4.1.2(1)-release. Upon login, home dir is displayed as tilde in PS1: pan@BJ-APN-2 ~$ echo $PS1 \[\033[35m\]\u@\h \w$ \[\033[0m\] pan@BJ-APN-2 ~$ pwd

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-13 Thread Chet Ramey
On 3/12/12 12:22 AM, Yongzhi Pan wrote: > Tested in GNU bash, version 3.00.16(1)-release and 4.1.2(1)-release. > > Upon login, home dir is displayed as tilde in PS1: > pan@BJ-APN-2 ~$ echo $PS1 > \[\033[35m\]\u@\h \w$ \[\033[0m\] > pan@BJ-APN-2 ~$ pwd > /export/home/pan/ > > After a cd command, w

Re: [bug] Home dir in PS1 not abbreviated to tilde

2012-03-12 Thread Clark J. Wang
On Mon, Mar 12, 2012 at 12:22, Yongzhi Pan wrote: > Tested in GNU bash, version 3.00.16(1)-release and 4.1.2(1)-release. > > Upon login, home dir is displayed as tilde in PS1: > pan@BJ-APN-2 ~$ echo $PS1 > \[\033[35m\]\u@\h \w$ \[\033[0m\] > pan@BJ-APN-2 ~$ pwd > /export/home/pan/ > > After a cd

[bug] Home dir in PS1 not abbreviated to tilde

2012-03-11 Thread Yongzhi Pan
Tested in GNU bash, version 3.00.16(1)-release and 4.1.2(1)-release. Upon login, home dir is displayed as tilde in PS1: pan@BJ-APN-2 ~$ echo $PS1 \[\033[35m\]\u@\h \w$ \[\033[0m\] pan@BJ-APN-2 ~$ pwd /export/home/pan/ After a cd command, which change directory to $HOME (not changed at all), it is