Re-add chdir in a portable way.