There are two possible sources of pwd
on my system: pwd
the bash
builtin, and /usr/bin/pwd
, which comes from GNU coreutils. When I issue cd //; pwd
(using the shell builtin), it types //
. However, when I issue cd //; /usr/bin/pwd
(using the external), it types /
. The actual working directory in both cases, as evidenced by ls
output and such, is always the same (the FS root).
Thus, the answer seems to be that there are two different concepts involved: the shell's idea of its working directory, and the actual process CWD. The builtin pwd
queries the former, while /usr/bin/pwd
(and any other binary) will only have access to the latter, and it's only the former which knows anything about //
. Why the shell's concept of a working directory distinguishes between /
and //
, and what //
is supposed to mean, I have no idea.
EDIT: Some searching comes across this question, which sheds some light. Apparently the weird behavior is standards-compliant, though it is still weird.
/
in a sequence is effectively parsed as one;cd //////var///tmp
andcd /var/tmp
have the same practical effect vis-a-vis where you end up on the filesystem. – DopeGhoti Nov 24 '15 at 20:53