You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by cr...@apache.org on 2004/09/05 04:32:41 UTC
svn commit: rev 43359 - forrest/trunk/src/core/bin
Author: crossley
Date: Sat Sep 4 19:32:40 2004
New Revision: 43359
Modified:
forrest/trunk/src/core/bin/forrest
Log:
1. The determination of FORREST_HOME works correctly if the symlink
to forrest is a relative pathname.
2. Removes the bash specific bits and replaces it with code that will work
under the Bourne Shell.
Issue: FOR-251
Submitted by: Rick Tessner
Modified: forrest/trunk/src/core/bin/forrest
==============================================================================
--- forrest/trunk/src/core/bin/forrest (original)
+++ forrest/trunk/src/core/bin/forrest Sat Sep 4 19:32:40 2004
@@ -36,9 +36,23 @@
if [ -z "$FORREST_HOME" ] ; then
# use the location of this script to infer $FORREST_HOME
- realpath_listing=$(ls -l $0)
- realpath="${realpath_listing#*-> }" # strip everything before '-> '
- realpath="/${realpath#*/}" # strip before '/' in case there wasn't a ->
+ 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"`/..
fi