Skip to content

Commit a3a6b06

Browse files
committed
Merge pull request sorintlab#555 from jskswamy/fix-test-running-on-osx
Use readlinkdashf function in test for cross compatibility with osx
2 parents 00d0431 + cba5e6a commit a3a6b06

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test

+22-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,28 @@
1111
#
1212
set -e
1313

14-
BASEDIR=$(readlink -f $(dirname $0))
14+
# Cross compatibility with osx
15+
# origin source: https://github.com/kubernetes/kubernetes/blob/master/hack/lib/init.sh#L102
16+
function readlinkdashf() {
17+
# run in a subshell for simpler 'cd'
18+
(
19+
if [[ -d "$1" ]]; then # This also catch symlinks to dirs.
20+
cd "$1"
21+
pwd -P
22+
else
23+
cd $(dirname "$1")
24+
local f
25+
f=$(basename "$1")
26+
if [[ -L "$f" ]]; then
27+
readlink "$f"
28+
else
29+
echo "$(pwd -P)/${f}"
30+
fi
31+
fi
32+
)
33+
}
34+
35+
BASEDIR=$(readlinkdashf $(dirname $0))
1536
BINDIR=${BASEDIR}/bin
1637

1738
if [ $PWD != $BASEDIR ]; then

0 commit comments

Comments
 (0)