--- bin/maven	2004-12-07 03:13:46.000000000 -0800
+++ bin/maven.new	2004-12-09 11:56:39.000000000 -0800
@@ -49,38 +49,30 @@
            ;;
 esac
 
-if [ -z "$MAVEN_HOME" ] ; then
-  # try to find MAVEN
-  if [ -d /opt/maven ] ; then
-    MAVEN_HOME=/opt/maven
-  fi
-
-  if [ -d "$HOME/maven" ] ; then
-    MAVEN_HOME="$HOME/maven"
-  fi
+# try to find MAVEN in well known locations
+[ -z "$MAVEN_HOME" -a -d /opt/maven ]		&& MAVEN_HOME=/opt/maven
+[ -z "$MAVEN_HOME" -a -d "$HOME/maven" ]	&& MAVEN_HOME="$HOME/maven"
 
+# Otherwise try to determine it from our invocation path
+if [ -z "$MAVEN_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"
-    else
-  PRG="$PRGDIR/$link"
-    fi
+  PRG="$0"    
+  while [ -h "$PRG" ]; do
+      ls=`ls -ld "$PRG"`
+      link=`expr "$ls" : '.*-> \(.*\)$'`
+      if expr "$link" : '/.*' > /dev/null; then
+          PRG="$link"
+      else
+          PRG="`dirname $PRG`/$link"
+      fi
   done
-
-  MAVEN_HOME="$PRGDIR/.."
-
-  # make it fully qualified
-  MAVEN_HOME=`cd "$MAVEN_HOME" && pwd`
+    
+  # Make it fully specified
+  cd "`dirname \"$PRG\"`/.."
+  MAVEN_HOME="`pwd -P`"
 
   cd "$saveddir"
 fi
