ACK_stoverflow
ACK_stoverflow

Reputation: 3305

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?

Upvotes: 3

Views: 246

Answers (2)

ACK_stoverflow
ACK_stoverflow

Reputation: 3305

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

Upvotes: 1

dimba
dimba

Reputation: 27581

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.

Upvotes: 1

Related Questions