Skip to content

Commit fdd4548

Browse files
committed
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
1 parent 5cbfd7c commit fdd4548

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ Release 0.22.0 - Unreleased
443443
HADOOP-7101. UserGroupInformation.getCurrentUser() fails when called from
444444
non-Hadoop JAAS context. (todd)
445445

446+
HADOOP-7089. Fix link resolution logic in hadoop-config.sh. (eli)
447+
446448
Release 0.21.1 - Unreleased
447449

448450
IMPROVEMENTS

bin/hadoop-config.sh

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,12 @@
1717
# should not be executable directly
1818
# also should not be passed any arguments, since we need original $*
1919

20-
# resolve links - $0 may be a softlink
21-
20+
# Resolve links ($0 may be a softlink) and convert a relative path
21+
# to an absolute path. NB: The -P option requires bash built-ins
22+
# or POSIX:2001 compliant cd and pwd.
2223
this="${BASH_SOURCE-$0}"
23-
while [ -h "$this" ]; do
24-
ls=`ls -ld "$this"`
25-
link=`expr "$ls" : '.*-> \(.*\)$'`
26-
if expr "$link" : '.*/.*' > /dev/null; then
27-
this="$link"
28-
else
29-
this=`dirname "$this"`/"$link"
30-
fi
31-
done
32-
33-
# convert relative path to absolute path
34-
common_bin=`dirname "$this"`
35-
script=`basename "$this"`
36-
common_bin=`cd "$common_bin"; pwd`
24+
common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
25+
script="$(basename -- "$this")"
3726
this="$common_bin/$script"
3827

3928
# the root of the Hadoop installation

0 commit comments

Comments
 (0)