fix cwd on unix (cherry-pick upstream bugfix)