PR: MNG-247

Submitted by: Jerome Lacoste
Reviewed by:  Brett Porter
make m2 shell script find home when it is a symlink


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@293186 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-03 00:16:36 +00:00
parent 4b0bf293fc
commit 5de7973576
1 changed files with 6 additions and 7 deletions

View File

@ -55,28 +55,27 @@ if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
saveddir=`pwd`
# need this for relative symlinks
PRGDIR=`dirname "$PRG"`
cd "$PRGDIR"
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '.*/.*' > /dev/null; then
PRG="$link"
PRG="$link"
else
PRG="$PRGDIR/$link"
PRG="`dirname "$PRG"`/$link"
fi
done
M2_HOME="$PRGDIR/.."
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched