You are comparing apples and pears here.
The xopen specification you are quoting, refers to the C-function chdir
.
The two shells I'm using (bash and zsh) have an internal command cd, and in both shells, a
cd ''
is interpreted as a no-op. This is explained in the man pages, for example for bash:
A null directory name in CDPATH is the same as the current directory, i.e., ``.''.
So this is the intended behaviour. Note that the standard you are quoting doesn't say anything about the shell's cd command.
I didn't check how the developers of bash and zsh actually implemented the cd command, but if they want to comply to their own specification, they must implement it (in C) similar to this:
if(argc == 0) {
chdir(getenv("HOME"));
} else if(strlen(argv[1]) == 0) {
chdir(".");
} else {
chdir(argv[1]);
}
If it's not done in this way, the behaviour of the chdir command would depend on the underlying implementation of the system library (and, yes, on the conformance to the xopen standard), and this would certainly be a bug in the shell implementation (though a different one than you are referring to).
UPDATE: As CoolRaoul correctly noted in his comment, my quote of the bash manpage is not relevant here, as it refers only to an empty element in the CDPATH, not to an empty argument of the cd
command. While it is reasonable to assume that the effect in both cases should be the same, this is not explicitly specified. The same is true for the zsh manpage. In both manpages, it is also not explicitly said that the cd command invokes the C function chdir
(although this also can reasonably assumed), nor do they seem to refer to any compliance to the xopen specification. At least for bash and zsh, I think we can safely say that the behaviour of cd ""
is simply unspecified.
BTW, I also tried it with the ksh which comes with Cygwin (and which identifies itself as MIRBSD KSH R50), and it behaves in the same way as bash and zsh.