bug-bash
[Top][All Lists]
Advanced

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

Re: rename directory and internal pwd command.


From: Masato Asou
Subject: Re: rename directory and internal pwd command.
Date: Thu, 28 Mar 2013 12:32:10 +0900 (JST)

From: Bob Proulx <address@hidden>
Date: Wed, 27 Mar 2013 11:20:35 -0600

> Masato Asou wrote:
>> 1. Go to directory ~/src.
>>     $ cd ~/src
>> 2. Rename the directory to ~/src-old.
>>     $ mv ~/src ~/src-old
>> 3. Invoke pwd command. Then print /home/asou/src by pwd command.
>>     $ pwd
>>     /home/asou/src
>> 4. Invoke /bin/pwd command. Then print /home/asou/src-old.
>>     $ /bin/pwd
>>     /home/asou/src-old
>> 
>> Is this a bug of internal pwd command?
> 
> This is an intentional feature.  Bash tracks your present working
> directory as changed by the cd command in the PWD variable.  The pwd
> command prints that variable.  When you arrived at the location
> $HOME/src the location was stored in the PWD variable.  Moving it out
> from under your current process had no effect on the value of the PWD
> variable.  Calling pwd prints the content of PWD variable.

Thank you for your careful comment.

> In the pwd documentation this is described briefly along with the -L
> and -P options for "logical" and "physical" behavior.  By default bash
> follows the logical chain of directories when performing commands
> which change the current directory.  The logical status is how you got
> there.  The intention is to make symbolic links invisible to the user.
> You could cd to a symlinked directory and then 'cd ..' would back you
> one logical directory out and return you to where you were.  Using a
> physical view the directory change through a symlink would place you
> in the new directory and a 'cd ..' would take you up from there.

> If you 'set -o physical' then bash will use the canonical physical
> structure of the file system when performing commands which change
> directories.

Sorry, I forgot to confirm the man bash.

> Personally I dislike the problems associated with the shell's logical
> view and always have 'set -o physical' in my .bashrc file so that I
> see the canonical physical file system directory structure.

I also agree with your opinion.

> The
> logical view is a thin facade that is too easily broken.  But the
> majority of users seem to prefer the logical view just the same.

Thanks.
--
ASOU Masato



reply via email to

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