Quantcast
Channel: How does bash continue to work correctly when you move its working directory? - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by user732 for How does bash continue to work correctly when you move its working directory?

$
0
0

Unix kernels keep track of what directory every process has for a working directory. You can prove this by cd'ing into a mounted volume, and then, as root, doing a umount on the mount point. You'll get some message about how the device is busy.

And clearly, modern shells have the working directory they say they have, otherwise programs that are children of the shell (C, Python or otherwise) wouldn't open the correct file when given a relative path on the command line.

But modern shells (ksh, bash, zsh, maybe others) play games with the working directory. You can prove this by creating a directory tree that has a symbolic link somewhere in the mid-levels:

% mkdir a% cd a% mkdir b.orig% ln -s b.orig b% mkdir b.orig/c% cd .. % cd a/b/c% pwd/home/bediger/a/b/c

That's all with zsh. It follows the symbolic link back up the tree, where, if it were just working it's way up using ".." directories, it would find a/b.orig/c


Viewing all articles
Browse latest Browse all 3

Trending Articles