路径“//”是什么意思?
What does the path "//" mean?
我刚刚在我的机器上找到目录 //
,现在我想知道它是什么意思。
user@dev:~$ cd /
user@dev:/$ pwd
/
user@dev:/$ cd //
user@dev://$ pwd
//
它显然是根目录,但我什么时候以及为什么要使用双斜杠而不是单斜杠?
是否与我在编程时使用的转义路径字符串有关?
例如:
string path = "//home//user//foo.file"
我也用 zsh 试过了,但它变成了通常的根目录 /
。所以我认为它是 bash 具体的。
这是 Pathname Resolution 规范的一部分:
A pathname consisting of a single <slash> shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. If a pathname begins with two successive <slash> characters, the first component following the leading <slash> characters may be interpreted in an implementation-defined manner, although more than two leading <slash> characters shall be treated as a single <slash> character.
因此,您的 shell 只是遵循规范而单独留下 //
,因为它 可能 在实现上被定义为 /
以外的东西.
我刚刚在我的机器上找到目录 //
,现在我想知道它是什么意思。
user@dev:~$ cd /
user@dev:/$ pwd
/
user@dev:/$ cd //
user@dev://$ pwd
//
它显然是根目录,但我什么时候以及为什么要使用双斜杠而不是单斜杠?
是否与我在编程时使用的转义路径字符串有关? 例如:
string path = "//home//user//foo.file"
我也用 zsh 试过了,但它变成了通常的根目录 /
。所以我认为它是 bash 具体的。
这是 Pathname Resolution 规范的一部分:
A pathname consisting of a single <slash> shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. If a pathname begins with two successive <slash> characters, the first component following the leading <slash> characters may be interpreted in an implementation-defined manner, although more than two leading <slash> characters shall be treated as a single <slash> character.
因此,您的 shell 只是遵循规范而单独留下 //
,因为它 可能 在实现上被定义为 /
以外的东西.