bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Yongzhi Pan
Subject: Re: [bug] Home dir in PS1 not abbreviated to tilde
Date: Wed, 14 Mar 2012 10:27:01 +0800

On Tue, Mar 13, 2012 at 8:58 PM, Chet Ramey <chet.ramey@case.edu> 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\]
> > pan@BJ-APN-2 ~$ pwd
> > /export/home/pan/
> >
> > After a cd command, which change directory to $HOME (not changed at all),
> > it is displayed as the complete path:
> > pan@BJ-APN-2 ~$ cd
> > pan@BJ-APN-2 /export/home/pan$
>
> Strictly speaking, the tilde prefix only extends up to the first slash.
> Pathname canonicalization cuts off the final slash of the directory
> name, so the directory target of `cd' (and therefore $PWD) won't match
> $HOME, and you won't get the abbreviation.  I'm surprised it matches the
> first time, but the pathname you get from the environment probably hasn't
> been canonicalized.
>
>
So is it OK that we compare $PWD and $HOME for the \w physically but not
literally? I mean if they are essentially the same directory, then we
abbreviate it. This may make it a little more friendly for my case below. ;)

> The reason is that my home in passwd has a trailing slash:
> > pan@BJ-APN-2 /export/home/pan$ grep ^$USER: /etc/passwd
> > pan:x:896:1::/export/home/pan/:/bin/bash
>
> >
> This isn't a good idea in any case.
>

I first created this directory, and later provided it in useradd. It is
tab-completed thus ends in a slash in the useradd command. It wasn't done
intentionally to produce this report.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]