LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   wierd, just curious (https://www.linuxquestions.org/questions/debian-26/wierd-just-curious-4175489836/)

danimalz 01-01-2014 06:25 PM

wierd, just curious
 
just messing around, i typed:

cd //

it appears i am in some directory //

if i 'ls' this directory it is the root directory

anyone know about this is it a bug?

astrogeek 01-01-2014 06:31 PM

Not a bug.

I do not recall where to find the refs at the moment, but in Unixland multiple /'s in paths are treated as a single / by the kernel/shell/filesystem.

So when you cd // it collapses those to cd / for filesystem use, but the environment variable that records the current directory remembers it as you typed it, //.

So you are in the // directory which is exactly the same as /.

Hope that made sense.

*** UPDATE ***

A quick search found this as part of the Single Unix Specification:

Quote:

3.266 Pathname

A character string that is used to identify a file. In the context of IEEE Std 1003.1-2001, a pathname consists of, at most, {PATH_MAX} bytes, including the terminating null byte. It has an optional beginning slash, followed by zero or more filenames separated by slashes. A pathname may optionally contain one or more trailing slashes. Multiple successive slashes are considered to be the same as one slash.
The important thing is that they are not an error, it is not a bug, they are legal, but the same as a single slash.


All times are GMT -5. The time now is 04:56 PM.