You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by el...@apache.org on 2011/01/14 09:01:28 UTC

svn commit: r1058881 - in /hadoop/common/trunk: CHANGES.txt bin/hadoop-config.sh

Author: eli
Date: Fri Jan 14 08:01:27 2011
New Revision: 1058881

URL: http://svn.apache.org/viewvc?rev=1058881&view=rev
Log:
HADOOP-7089. Fix link resolution logic in hadoop-config.sh. Contributed by Eli Collins

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/bin/hadoop-config.sh

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1058881&r1=1058880&r2=1058881&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Fri Jan 14 08:01:27 2011
@@ -443,6 +443,8 @@ Release 0.22.0 - Unreleased
     HADOOP-7101. UserGroupInformation.getCurrentUser() fails when called from
     non-Hadoop JAAS context. (todd)
 
+    HADOOP-7089. Fix link resolution logic in hadoop-config.sh. (eli)
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/common/trunk/bin/hadoop-config.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/bin/hadoop-config.sh?rev=1058881&r1=1058880&r2=1058881&view=diff
==============================================================================
--- hadoop/common/trunk/bin/hadoop-config.sh (original)
+++ hadoop/common/trunk/bin/hadoop-config.sh Fri Jan 14 08:01:27 2011
@@ -17,23 +17,12 @@
 # should not be executable directly
 # also should not be passed any arguments, since we need original $*
 
-# resolve links - $0 may be a softlink
-
+# Resolve links ($0 may be a softlink) and convert a relative path
+# to an absolute path.  NB: The -P option requires bash built-ins
+# or POSIX:2001 compliant cd and pwd.
 this="${BASH_SOURCE-$0}"
-while [ -h "$this" ]; do
-  ls=`ls -ld "$this"`
-  link=`expr "$ls" : '.*-> \(.*\)$'`
-  if expr "$link" : '.*/.*' > /dev/null; then
-    this="$link"
-  else
-    this=`dirname "$this"`/"$link"
-  fi
-done
-
-# convert relative path to absolute path
-common_bin=`dirname "$this"`
-script=`basename "$this"`
-common_bin=`cd "$common_bin"; pwd`
+common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
+script="$(basename -- "$this")"
 this="$common_bin/$script"
 
 # the root of the Hadoop installation