Double root folder vs single root folder
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Dream Voyager Looping
--
Chapters
00:00 Double Root Folder Vs Single Root Folder
00:39 Answer 1 Score 1
00:57 Answer 2 Score 0
01:08 Answer 3 Score 0
01:52 Accepted Answer Score 17
02:30 Thank you
--
Full question
https://superuser.com/questions/188477/d...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #bash
#avk47
ACCEPTED ANSWER
Score 17
From Bash FAQ E10:
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'.
ANSWER 2
Score 1
"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.
ANSWER 3
Score 0
Multiple slashes are just ignored by the tools you have used and you are always getting to the same root folder.
ANSWER 4
Score 0
Multiple 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: http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11 The meaning of "//" is left undefined by the standards, but "///" and more slashes are equivalent to "/".