Strange command prompt behavior of cd
I've tried this in CentOS 5.6 and Debian 6.02, both guests running under VirtualBox 4.04, and it works in both.
If you type cd /开发者_如何转开发/
, it takes you to root like normal, but the pwd is //
. Other than that, everything is like a regular root. You can traverse the filesystem like normal, but as long as all the paths you enter are relative, the double //
will remain. What's going on here?
You've probably using bash
. At least on my system bash behaves as you've described.
While trying it in zsh
and tcsh
pwd was /
as expected. So I guess it some sort of bash only "problem".
Note: if you do cd ///
than pwd is /. So it looks like a "bug" in bash.
From the accepted answer at the link given by delnan:
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.
Looks like it's a part of the Single Unix Spec.
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11
精彩评论