我们知道根目录是/,根据posix,还有另一个目录//与/不同。当使用ls /和ls //时,输出与stat相同,但是,如果cd /和cd //则输出不同,尽管目录内容相同。那真的让我感到困惑。有人得到答案了吗?
从Bash常见问题解答:
E10) Why does `cd //' leave $PWD as `//'? POSIX.2, in its description of `cd', says that *three* or more leading slashes may be replaced with a single slash when canonicalizing the current working directory. This is, I presume, for historical compatibility. Certain versions of Unix, and early network file systems, used paths of the form //hostname/path to access `path' on server `hostname'.