Test for the existence of getcwd, and use it only when found.