【问题标题】:What is path //, how is it different from /什么是路径//,它与/有什么不同
【发布时间】:2013-05-26 07:24:39
【问题描述】:

我们知道根目录是/,根据posix,还有另一个目录//与/不同。当你 ls / 和 ls // 时,输出是一样的,就像 stat,但是如果你 cd / 和 cd //,它们是不同的,尽管目录内容是一样的。 这真的让我很困惑。有人回答了吗?

【问题讨论】:

  • 你能提供一个说明它们不同的参考吗?另外,如果“cd /”和“cd //”它们是不同的,你是什么意思——你怎么知道?
  • @MarkkuK。对不起,我没有说清楚,这意味着密码没有改变。正如devnull所说。你可以试试看。
  • 另外,如果你输入“cd //usr”(例如)而不是“cd /usr”,你最终会进入“/usr”,bash 说你是 un“//usr”并且 pwd 也是“//usr”...

标签: linux kernel posix pathname


【解决方案1】:

来自Bash FAQ

E10) Why does `cd //' leave $PWD as `//'?

POSIX.2, in its description of `cd', says that *three* or more leading
slashes may be replaced with a single slash when canonicalizing the
current working directory.

This is, I presume, for historical compatibility.  Certain versions of
Unix, and early network file systems, used paths of the form
//hostname/path to access `path' on server `hostname'.

【讨论】:

  • 在我的 git bash 仿真(技术上是一台 Windows 机器)上尝试 ls -l // 导致机器试图读取并列出整个可用网络......哇。
猜你喜欢
  • 1970-01-01
  • 2017-02-20
  • 2021-02-12
  • 2011-11-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-31
相关资源
最近更新 更多