Make setCWD() with bad paths safer
Make setCWD() with bad paths safer

Summary: Ref T10853. This isn't a complete fix, but should prevent the most serious mistakes with setCWD() on bad paths.

Test Plan:
  - Wrote a script using `setCWD()`.
  - Gave it a bad path: got an explicit error.
  - Gave it a good path: things worked great.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10853

Differential Revision: https://secure.phabricator.com/D15785

wikimedia/phabricator-libphutil,uhd-urz/libphutil,r4nt/libphutil,uber/libphutil,Khan/libphutil,aik099/libphutil,uber/libphutil,devurandom/libphutil,uhd-urz/libphutil,aik099/libphutil,codelabs-ch/libphutil,Khan/libphutil,devurandom/libphutil,Khan/libphutil,aik099/libphutil,devurandom/libphutil,codelabs-ch/libphutil,uber/libphutil,wikimedia/phabricator-libphutil,uhd-urz/libphutil,wikimedia/phabricator-libphutil,codelabs-ch/libphutil,r4nt/libphutil,r4nt/libphutil