/ 和 //
看下面这个的例子:
[wangcong@cr0 ~]$ cd /
[wangcong@cr0 /]$ pwd
/
[wangcong@cr0 /]$ cd //
[wangcong@cr0 //]$ pwd
//
[wangcong@cr0 //]$ cd ///
[wangcong@cr0 /]$ pwd
/
[wangcong@cr0 /]$ cd ////
[wangcong@cr0 /]$ pwd
/
其实 POSIX 规范里有讲到,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. A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.
大多数实现,包括 bash,都是把 // 当 / 来处理,但是仍然显示 //。但 zsh 不是,zsh 把 // 当 / 处理并显示。