Sometimes the *shell* buffer's directory tracking gets out of sync
with its inferior shell process. In such cases, "M-x dirs RET"
usually fixes the problem, but this doesn't work if there is a space
in the directory's name:
M-x shell RET
$ cd /tmp
$ mkdir 'one two'
$ X='one two'; cd "$X"
[ using $X here to deliberately confused comint ]
M-x dirs RET => "Couldn't cd"
I see "$ dirs" and "/tmp/one two" shown in the *shell* buffer, but an
attempt is made to cd to "/tmp/one", rather than to "/tmp/one two".
I realise that it's not possible to parse the output of 'dirs', since
spaces in the path look identical to spaces separating the paths, but
perhaps "dirs +0" could be used when it is detected that the shell is
bash?