I always thought of this tracking of your current directory
to be shell magic just for the convenience of the user, eg
an example (run on linux)
$ cd /usr/X11
$ pwd
/usr/X11
$ /bin/pwd
/usr/X11R6
$ ls -ld /usr/X11
lrwxrwxrwx 1 root root 5 Oct 21 1999 /usr/X11 -> X11R6
But I see what you are saying in the case of
the current directory being a deleted directory, eg :-
$ mkdir test
cd test
pwd ; /bin/pwd
/home/ncw/test
/home/ncw/test
rmdir .
$ pwd ; /bin/pwd
/home/ncw/test
/bin/pwd: cannot get current directory: No such file or directory
Anyway, getcwd() was what I expected Cwd to use, and I was
very suprised to see this /bin/pwd thing!
Thanks for the explanation. I think from the above
experinents /bin/pwd == getcwd() under linux, so on that
platform at least it should be replaced with getcwd().
According to my man pages getcwd() is POSIX so pretty
much any unix should support it now-a-days.