Closed csw closed 9 years ago
Awesome analysis, thanks. I think that line exists in most of our shell scripts and I saw a similar patch go by recently for one. Let's go with redirecting cd
to /dev/null
.
With a comment explaining why!
Maybe unsetting CDPATH is the right thing to do. I don't see how letting the environment mess with our cd
invocations can do anything but break.
When attempting to install multirust, I got an odd sequence of errors from gen-installer.sh, starting with:
I use Mac OS X, where /bin/sh is bash, and I have CDPATH set to a value including
.
. It turns out that the problem is with this shell script construction:$(cd $(dirname "$0") && pwd)
. (Really, any sort of$(cd $foo && pwd)
.) Whendirname "$0"
does not start with.
or/
, and CDPATH includes.
, bash's cd builtin echoes the selected directory to stdout. (Arguably this is a bash bug, since this behavior makes no sense for non-interactive use...) Multirust triggers this by invoking gen-installer assrc/rust-installer/gen-installer.sh
.This could be fixed by redirecting the output of cd to /dev/null (
$(cd $(dirname "$0") >/dev/null && pwd)
), or by addingunset CDPATH
to the shell scripts. I'm not sure which would be preferable, stylistically, but I'd be happy to put a pull request together.