Why is there a // directory?
I just found a very weird feature (bug?) with my computer's file system. I can do cd //
and it will go to the //
directory, but display all the same files as the /
directory. Why is this? If I cd ..
while in /
, it will stay at /
. //
is the only one that works -- I tried multiple slashes, but it just stays in /
.
From the POSIX spec:
3.266: ... Multiple successive slashes are considered to be the same as one slash.
4.11: ... A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.
The second part means that a path beginning with // can have a special meaning. This is rarely if ever used, and can be a source of bugs: https://stackoverflow.com/a/7816833/163956.
It seems like Bash will normalize pathnames, but does not normalize double slashes at the beginning of a pathname. This is understandable, as on some Unix systems (though not Mac OS X), //
may indicate a network path and Bash is intended to be portable. See this question on Unix.SE for the double-slash issue.
Since in Mac OS X //
has no special meaning, you're actually in /
.