Correctly interpreting symlinks

This commit is contained in:
Jose Lorenzo Rodriguez 2011-10-14 22:05:43 -04:30
parent 3b8ca96428
commit 856b34f9f5

View file

@ -18,16 +18,15 @@
# @license MIT License (http://www.opensource.org/licenses/mit-license.php)
#
################################################################################
LIB=${0}
SYM=$(readlink "$0")
LIB=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && LIB=$LIB/$(basename -- "$0")
if [ ! -n "$SYM" ]
then
LIB=${LIB%/*}"/"
else
LIB=${SYM%/*}"/"
fi
while [ -h $LIB ]; do
DIR=$(dirname -- "$LIB")
SYM=$(readlink $LIB)
LIB=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
done
LIB=$(dirname -- "$LIB")/
APP=`pwd`
exec php -q ${LIB}cake.php -working "${APP}" "$@"