HADOOP-7089. Fix link resolution logic in hadoop-config.sh. Contributed by Eli Collins

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1058881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2011-01-14 08:01:27 +00:00
parent ebb7b7f088
commit 3d1b9ca1e3
2 changed files with 7 additions and 16 deletions

View File

@ -443,6 +443,8 @@ Release 0.22.0 - Unreleased
HADOOP-7101. UserGroupInformation.getCurrentUser() fails when called from HADOOP-7101. UserGroupInformation.getCurrentUser() fails when called from
non-Hadoop JAAS context. (todd) non-Hadoop JAAS context. (todd)
HADOOP-7089. Fix link resolution logic in hadoop-config.sh. (eli)
Release 0.21.1 - Unreleased Release 0.21.1 - Unreleased
IMPROVEMENTS IMPROVEMENTS

View File

@ -17,23 +17,12 @@
# should not be executable directly # should not be executable directly
# also should not be passed any arguments, since we need original $* # 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}" this="${BASH_SOURCE-$0}"
while [ -h "$this" ]; do common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
ls=`ls -ld "$this"` script="$(basename -- "$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`
this="$common_bin/$script" this="$common_bin/$script"
# the root of the Hadoop installation # the root of the Hadoop installation