Homebrew/homebrew — pull request #34246 by thfanning (2014-11-17 03:31:45+00:00)
Title: Avoid spurious output from cd command.

When `brew` is invoked by a relative pathname and `CDPATH` has been exported (typically with `.` as the first element) then the `cd` command will generate output that messes up the definition of `BREW_FILE_DIRECTORY`. To demonstrate the error:
```
export CDPATH=.
$ cd `brew --prefix`
$ bin/brew
```
this generates the following output:
```
bin/brew: line 13: cd: /usr/local/bin
/usr/local/bin/../Library: No such file or directory
bin/brew: line 23: /brew.rb: No such file or directory
bin/brew: line 23: exec: /brew.rb: cannot execute: No such file or directory
```
The error is caused by `BREW_FILE_DIRECTORY` containing duplicate words, one from the `cd` command and one from the `pwd` command.

Obviously, `CDPATH` should not be exported...