Author: rgardler
Date: Sat Dec 24 02:46:49 2005
New Revision: 358925
URL: http://svn.apache.org/viewcvs?rev=358925&view=rev
Log:
1. The symlink resolution does not handle chained symlinks
2. The value assigned to FORREST_HOME is not canonical
3. Command line arguments are passed to ant as $@ instead of "$@"
(thanks to Richard Calmbach
FOR-771)
Modified:
forrest/trunk/bin/forrest
Modified: forrest/trunk/bin/forrest
URL:
http://svn.apache.org/viewcvs/forrest/trunk/bin/forrest?rev=358925&r1=358924&r2=358925&view=diff
==============================================================================
--- forrest/trunk/bin/forrest (original)
+++ forrest/trunk/bin/forrest Sat Dec 24 02:46:49 2005
@@ -37,24 +37,27 @@
if [ -z "$FORREST_HOME" ] ; then
# use the location of this script to infer $FORREST_HOME
- whoami=`basename $0`
- whereami=`echo $0 | sed -e "s#^[^/]#\`pwd\`/&#"`
- whereami=`dirname $whereami`
-
- # Resolve any symlinks of the now absolute path, $whereami
- realpath_listing=`ls -l $whereami/$whoami`
- case "$realpath_listing" in
- *-\>\ /*)
- realpath=`echo $realpath_listing | sed -e "s#^.*-> ##"`
- ;;
- *-\>*)
- realpath=`echo $realpath_listing | sed -e "s#^.*-> #$whereami/#"`
- ;;
- *)
- realpath=$whereami/$whoami
- ;;
- esac
- FORREST_HOME=`dirname "$realpath"`/..
+
+ thisprg="$0"
+
+ # Resolve links - $thisprg may be a symbolic link
+
+ while [ -h "$thisprg" ] ; do
+ ls=`ls -ld "$thisprg"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+
+ if expr "$link" : '/.*' > /dev/null; then
+ thisprg="$link"
+ else
+ thisprg=`dirname "$thisprg"`/"$link"
+ fi
+ done
+
+ FORREST_HOME=`dirname "$thisprg"`/..
+
+ # Make it fully qualified
+
+ FORREST_HOME=`cd "$FORREST_HOME" && pwd`
fi
# Save old ANT_HOME
@@ -94,7 +97,7 @@
echo "Apache Forrest. Run 'forrest -projecthelp' to list options"
echo
export FORREST_HOME
-"$ANT_HOME/bin/ant" --noconfig -buildfile "$ANTFILE" -Dbasedir="$PROJECT_HOME"
-emacs $@
+"$ANT_HOME/bin/ant" --noconfig -buildfile "$ANTFILE" -Dbasedir="$PROJECT_HOME"
-emacs "$@"
RESULT=$?
# ---- Restore Classpath