It's important to note that bash has a built-in pwd command, which uses internal state information to determine the working directory, rather than doing the walk up the tree that /bin/pwd does.
Here's an example that illustrates the difference:
[root@localhost ~]# cd /usr/local/share [root@localhost share]# pwd /usr/local/share [root@localhost share]# /bin/pwd /import/share [root@localhost share]#
On the system used above, /usr/local/share is a symlink to an NFS mounted file system. Bash's built-in pwd command shows the "logical" path, whereas /bin/pwd shows the actual path of the mounted file system.
In your example, the internal state of bash still knows the working directory by its old name (before the second mv command changed it again). It's not clear what shell you were using prior to running bash (and after exiting it), but it may be using /bin/pwd in any case.
Gilbert
On 16/04/2014 3:12 PM, Robert Keizer wrote:
I ran into this earlier today and thought I'd share.
Shell fails.
sh-4.2$ pwd /tmp/a sh-4.2$ mv /tmp/a /tmp/b sh-4.2$ pwd /tmp/b sh-4.2$ bash robert.keizer@qubit:/tmp/b$ mv /tmp/b /tmp/c robert.keizer@qubit:/tmp/b$ pwd /tmp/b robert.keizer@qubit:/tmp/b$ ls -alh /tmp/ | grep ^d.*c$ drwxr-xr-x 2 robert.keizer robert.keizer 4.0K Apr 16 16:09 c robert.keizer@qubit:/tmp/b$ ls -alh /tmp/ | grep ^d.*b$ robert.keizer@qubit:/tmp/b$ exit sh-4.2$ pwd /tmp/c sh-4.2$