浏览代码

HADOOP-566. Fix scripts to work correctly when accessed through relative symbolic links. Contributed by Lee Faris.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@452166 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 年之前
父节点
当前提交
606db081b7
共有 2 个文件被更改,包括 11 次插入4 次删除
  1. 3 0
      CHANGES.txt
  2. 8 4
      bin/hadoop-config.sh

+ 3 - 0
CHANGES.txt

@@ -103,6 +103,9 @@ Trunk (unreleased changes)
 25. HADOOP-552.  Improved error checking when copying map output files
     to reduce nodes.  (omalley via cutting)
 
+26. HADOOP-566.  Fix scripts to work correctly when accessed through
+    relative symbolic links.  (Lee Faris via cutting)
+
 
 Release 0.6.2 - 2006-09-18
 

+ 8 - 4
bin/hadoop-config.sh

@@ -3,10 +3,8 @@
 # also should not be passed any arguments, since we need original $*
 
 # resolve links - $0 may be a softlink
-bin=`dirname "$0"`
-script=`basename "$0"`
-bin=`cd "$bin"; pwd`
-this="$bin/$script"
+
+this="$0"
 while [ -h "$this" ]; do
   ls=`ls -ld "$this"`
   link=`expr "$ls" : '.*-> \(.*\)$'`
@@ -17,6 +15,12 @@ while [ -h "$this" ]; do
   fi
 done
 
+# convert relative path to absolute path
+bin=`dirname "$this"`
+script=`basename "$this"`
+bin=`cd "$bin"; pwd`
+this="$bin/$script"
+
 # the root of the Hadoop installation
 export HADOOP_HOME=`dirname "$this"`/..