Double root folder vs single root folder
On my Linux box, in bash, I have access to a "double root" folder denoted by two forward slashes:
tomas:~ $ cd /
tomas:/ $ ls
bin/ cdrom@ ...
tomas:/ $ cd //
tomas:// $ ls
bin/ cdrom@ ...The content of the folder and its subfolder is identical to the "normal" single slash root. The double slash does not go away when I access its subfolders. The annomaly does not repeat itself with three or more slashes; these are simple synonyms for the root:
tomas:// $ cd home/tomas
tomas://home/tomas $ cd ///
tomas:/ $ cd ////
tomas:/ $What kindof place is it? Is it a bug? Can anyone explain the annomaly?
14 Answers
From Bash FAQ E10:
2E10) 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'.
"It's not a bug, it's a feature!"
You're still in the same root directory. I don't know the origins of this, but suspect it may have something to do with building strings for absolute paths. If anyone else knows for sure, pipe up.
Multiple slashes are just ignored by the tools you have used and you are always getting to the same root folder.
1Multiple slashes are treated as a single slash for pathname-resolution purposes.
What you're seeing in the shell prompt is an artifact of bash PS1 handling (see section "PROMPTING" in the bash manpage).
[root@linux /]# cd / ; echo $PWD
/
[root@linux /]# cd // ; echo $PWD
//
[root@linux //]# cd /// ; echo $PWD
/
[root@linux /]# cd //// ; echo $PWD
/The result is only a matter of presentation; you're always in the same root directory. You can check this by looking at /proc/$$/root.
[edit] Well I never knew this: The meaning of "//" is left undefined by the standards, but "///" and more slashes are equivalent to "/".