19

ルート ディレクトリが / であることはわかっていますが、posix によると、/ とは異なる別のディレクトリ // があります。ls / と ls // を実行すると、stat と同じように出力が同じになりますが、cd / と cd // を実行すると、ディレクトリの内容は同じですが、出力が異なります。それは本当に私を混乱させました。誰でも答えを得ましたか?

4

1 に答える 1

25

Bash FAQから:

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'.
于 2013-05-30T16:32:43.837 に答える