Bash moves in mysterious ways
Playing with the mv command I ran into this:
From a safe location create 2 Directories, create some files in one of the directories and enter that directory:
Nothing special this far all is where you expect it to be. Now the fun part.
Move the directory you are standing in to the other directory:
No errors. But which directory are you presently in?
The build-in places you at /home/druuna/Temp/Temp_01. Sounds reasonable, that is where you cd-ed into.
But the binary version places you in home/druuna/Temp/Temp_02/Temp_01. Also sounds reasonable, that is where you moved yourself to.... Hmmmm.
You are actually standing in /home/druuna/Temp/Temp_02/Temp_01:
Like I said: Bash moves in mysterious ways 
Here's another example where pwd (the build-in) is "wrong":
The build-in pwd can be wrong and I would advise you to use /bin/pwd instead.
From a safe location create 2 Directories, create some files in one of the directories and enter that directory:
Code:
$ mkdir Temp_0{1,2}
$ ls -la
total 40
drwxr-x--- 4 druuna internet 4096 Dec 4 20:16 .
drwxr-x--- 38 druuna internet 28672 Dec 4 20:16 ..
drwxr-x--- 2 druuna internet 4096 Dec 4 20:16 Temp_01
drwxr-x--- 2 druuna internet 4096 Dec 4 20:16 Temp_02
$ touch Temp_01/{foo,bar}
$ ls -la *
Temp_01:
total 8
drwxr-x--- 2 druuna internet 4096 Dec 4 20:17 .
drwxr-x--- 4 druuna internet 4096 Dec 4 20:16 ..
-rw-r----- 1 druuna internet 0 Dec 4 20:17 bar
-rw-r----- 1 druuna internet 0 Dec 4 20:17 foo
Temp_02:
total 8
drwxr-x--- 2 druuna internet 4096 Dec 4 20:16 .
drwxr-x--- 4 druuna internet 4096 Dec 4 20:16 ..
$ cd Temp_01/
$ pwd ; /bin/pwd
/home/druuna/Temp/Temp_01
/home/druuna/Temp/Temp_01
~/Temp/Temp_01 $ ls -la
total 8
drwxr-x--- 2 druuna internet 4096 Dec 4 20:17 .
drwxr-x--- 4 druuna internet 4096 Dec 4 20:16 ..
-rw-r----- 1 druuna internet 0 Dec 4 20:17 bar
-rw-r----- 1 druuna internet 0 Dec 4 20:17 foo
Move the directory you are standing in to the other directory:
Code:
$ pwd ; /bin/pwd /home/druuna/Temp/Temp_01 /home/druuna/Temp/Temp_01 $ mv ../Temp_01 ../Temp_02
Code:
$ pwd ; /bin/pwd /home/druuna/Temp/Temp_01 /home/druuna/Temp/Temp_02/Temp_01
But the binary version places you in home/druuna/Temp/Temp_02/Temp_01. Also sounds reasonable, that is where you moved yourself to.... Hmmmm.
You are actually standing in /home/druuna/Temp/Temp_02/Temp_01:
Code:
$ cd .. $ pwd ; /bin/pwd /home/druuna/Temp/Temp_02 /home/druuna/Temp/Temp_02 $ ls -la total 12 drwxr-x--- 3 druuna internet 4096 Dec 4 20:19 . drwxr-x--- 3 druuna internet 4096 Dec 4 20:19 .. drwxr-x--- 2 druuna internet 4096 Dec 4 20:17 Temp_01 $ ls -l Temp_01/ total 0 -rw-r----- 1 druuna internet 0 Dec 4 20:17 bar -rw-r----- 1 druuna internet 0 Dec 4 20:17 foo

Here's another example where pwd (the build-in) is "wrong":
Code:
$ mkdir Temp $ cd Temp/ $ touch foo $ ls -l total 0 -rw-r----- 1 druuna internet 0 Dec 4 20:49 foo $ rm -rf ../Temp/ $ pwd /home/druuna/Temp/Temp $ /bin/pwd /bin/pwd: couldn't find directory entry in `..' with matching i-node $ ls -l total 0 $ cd .. $ ls -la total 32 drwxr-x--- 2 druuna internet 4096 Dec 4 20:49 . drwxr-x--- 38 druuna internet 28672 Dec 4 20:16 ..




