prompt display when cd to dir symoblic link

Denys Vlasenko vda.linux at googlemail.com
Thu Apr 2 07:28:31 UTC 2015


On Wed, Apr 1, 2015 at 3:42 PM, santosh <ysan99 at gmail.com> wrote:
> On Wed, Apr 1, 2015 at 5:48 PM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
>> On Wed, Apr 1, 2015 at 4:39 AM, santosh <ysan99 at gmail.com> wrote:
>>> Hello!
>>>
>>> I have a link to directory.
>>>
>>> /var/test --> /hdd1/test.
>>>
>>> /$pwd
>>> /
>>> $cd /var/test
>>> /hdd/test$
>>>
>>> The prompt's PS1 w should displays real directory name.
>>> I like it to display like
>>>
>>> /var/test$
>>>
>>> Is there anything I can configure to get this behavior?
>>
>> No.
>>
>> In Unix, current directory is always physical.
>> You can't really "cd to a symlink".
>> When you do that, your current directory
>> will be where symlink points to, not the symlink.
>
> But busybox ash prompt displays physical unlike bash..

I know.

Bash is lying to you.

> Here I'm pasting the output from bash and busybox ash.
>
> BASH:
> root at cmx52:~# ll /var/test
> lrwxrwxrwx    1 root     root            10 Apr  1 13:35 /var/test -> /hdd1/test
> root at cmx52:~# echo $PS1
> \u@\h:\w\$
> root at cmx52:~# cd /var/test
> root at cmx52:/var/test# pwd
> /var/test

Yes, bash shows that, but the *real* getcwd system call
returns "/hdd1/test" in this case.

You *can't* have a symlink as a current directory.
It's just not possible in Linux.


More information about the busybox mailing list