Be aware when calling getcwd() in directories consisting of symlinks.
getcwd() is the equivalent of shell command "pwd -P" which resolves symlinks.
The shell command "pwd" is the equivalent of "pwd -L" which uses PWD from the environment without resolving symlinks. This is also the equivalent of calling getenv('PWD').