Port 9452d5e1b6d0eec733b00e091933d51c10bd460e from cakephp/cakephp

Harden the `bin/cake` script to avoid breakage when local shell
environment has a `CDPATH` set.