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

This commit is contained in:
Brian Porter 2014-05-19 11:05:28 -05:00
parent 0fd12c7a68
commit 9452d5e1b6

View file

@ -24,12 +24,12 @@ canonicalize() {
if [ -f "$NAME" ] if [ -f "$NAME" ]
then then
DIR=$(dirname -- "$NAME") DIR=$(dirname -- "$NAME")
NAME=$(cd -P "$DIR" && pwd -P)/$(basename -- "$NAME") NAME=$(cd -P "$DIR" > /dev/null && pwd -P)/$(basename -- "$NAME")
fi fi
while [ -h "$NAME" ]; do while [ -h "$NAME" ]; do
DIR=$(dirname -- "$NAME") DIR=$(dirname -- "$NAME")
SYM=$(readlink "$NAME") SYM=$(readlink "$NAME")
NAME=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") NAME=$(cd "$DIR" > /dev/null && cd $(dirname -- "$SYM") > /dev/null && pwd)/$(basename -- "$SYM")
done done
echo "$NAME" echo "$NAME"
} }