What's happening when you do 'cd //'?

2

This is just trivia really, but it's just got me wondering what's going on. I accidentally hit / instead of . today and got this:

[andrew.morris@server ~]$ cd //
[andrew.morris@server //]$ pwd
/

I would have thought // was an invalid path. What happened?

voltrevo

Posted 2014-10-21T02:03:27.400

Reputation: 121

Question was closed 2014-10-21T06:06:11.253

Answers

3

For the most part, repeated slahes in a path are equivalent to a single slash. This behavior is mandated by POSIX and most applications follow suit. The exception is that “a pathname that begins with two successive slashes may be interpreted in an implementation-defined manner” (but ///foo is equivalent to /foo).

From this answer: https://unix.stackexchange.com/questions/12283/unix-difference-between-path-starting-with-and

Gaurav Joseph

Posted 2014-10-21T02:03:27.400

Reputation: 1 503