In unix/linux, any number of consecutive forwardslashes in a path is generally equivalent to a single forwardslash. eg.
$ cd /home/shum
$ pwd
/home/shum
$ cd /home//shum
$ pwd
/home/shum
$ cd /home///shum
$ pwd
/home/shum
Yet for some reason two forwardslashes at the beginning of an absolute path is treated specially. eg.
$ cd ////home
$ pwd
/home
$ cd ///
$ pwd
/
$ cd //
$ pwd
//
$ cd home//shum
$ pwd
//home/shum
Any other number of consecutive forwardslashes anywhere else in a patch gets truncated, but two at the beginning will remain, even if you then navigate around the filesystem relative to it.
Why is this? Is there any difference between /... and //... ?
zsh
or the like./usr/bin/namei
, but it is not related. 2) It is a shell thing, since it only happens withsh
andbash
, but not withzsh/csh/tcsh
, nor with thechdir()
syscall. 3) It happens on "the others" - I just tested NetBSD 5.0 and FreeBSD 6.3, andcd //bin
shows exactly the same behavior.