Skip to main content
added 221 characters in body
Source Link
Jörg W Mittag
  • 4.3k
  • 21
  • 24

According to the POSIX specification, paths that begin with exactly two slashes have implementation-defined semantics.

Multiple slashes in a path are collapsed to one slash, except for the case where there is exactly two slashes at exactly the beginning of the path.

So, /foo, ///foo, ////foo, and ///////////////////foo are guaranteed to be the same path, /foo/bar, /foo//bar, /foo///bar, and so on are guaranteed to be the same path, but /foo and //foo are not guaranteed to be the same path, and neither are //foo and ///foo – any implementation can define the semantics as they wish. They could choose to define //foo to mean the same thing as /foo and ///foo, but they don't have to.

The intention is that operating systems can use paths beginning with // to implement semantics that are different from POSIX file system semantics.

For example, a hypothetical hybrid of Windows and Unix could use // for Windows filesystem semantics. Cygwin actually uses // for network paths, similar to how Windows uses \\.

In Cygwin, for example, cd //; ls would list all SMB fileserver on the local network, not the root directory!

According to the POSIX specification, paths that begin with exactly two slashes have implementation-defined semantics.

Multiple slashes in a path are collapsed to one slash, except for the case where there is exactly two slashes at exactly the beginning of the path.

So, /foo, ///foo, ////foo, and ///////////////////foo are the same path, /foo/bar, /foo//bar, /foo///bar, and so on are the same path, but /foo and //foo are not the same path, and neither are //foo and ///foo.

The intention is that operating systems can use paths beginning with // to implement semantics that are different from POSIX file system semantics.

For example, a hypothetical hybrid of Windows and Unix could use // for Windows filesystem semantics. Cygwin actually uses // for network paths, similar to how Windows uses \\.

In Cygwin, for example, cd //; ls would list all SMB fileserver on the local network, not the root directory!

According to the POSIX specification, paths that begin with exactly two slashes have implementation-defined semantics.

Multiple slashes in a path are collapsed to one slash, except for the case where there is exactly two slashes at exactly the beginning of the path.

So, /foo, ///foo, ////foo, and ///////////////////foo are guaranteed to be the same path, /foo/bar, /foo//bar, /foo///bar, and so on are guaranteed to be the same path, but /foo and //foo are not guaranteed to be the same path, and neither are //foo and ///foo – any implementation can define the semantics as they wish. They could choose to define //foo to mean the same thing as /foo and ///foo, but they don't have to.

The intention is that operating systems can use paths beginning with // to implement semantics that are different from POSIX file system semantics.

For example, a hypothetical hybrid of Windows and Unix could use // for Windows filesystem semantics. Cygwin actually uses // for network paths, similar to how Windows uses \\.

In Cygwin, for example, cd //; ls would list all SMB fileserver on the local network, not the root directory!

Source Link
Jörg W Mittag
  • 4.3k
  • 21
  • 24

According to the POSIX specification, paths that begin with exactly two slashes have implementation-defined semantics.

Multiple slashes in a path are collapsed to one slash, except for the case where there is exactly two slashes at exactly the beginning of the path.

So, /foo, ///foo, ////foo, and ///////////////////foo are the same path, /foo/bar, /foo//bar, /foo///bar, and so on are the same path, but /foo and //foo are not the same path, and neither are //foo and ///foo.

The intention is that operating systems can use paths beginning with // to implement semantics that are different from POSIX file system semantics.

For example, a hypothetical hybrid of Windows and Unix could use // for Windows filesystem semantics. Cygwin actually uses // for network paths, similar to how Windows uses \\.

In Cygwin, for example, cd //; ls would list all SMB fileserver on the local network, not the root directory!