Skip to content

Commit

Permalink
Add realpath function
Browse files Browse the repository at this point in the history
  • Loading branch information
pj.fanning authored and Emily Curtin committed Oct 31, 2017
1 parent adce905 commit d0d4908
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bin/spark-bench.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
#!/bin/bash
set -eu

realpath () {
(
TARGET_FILE="$1"

cd "$(dirname "$TARGET_FILE")"
TARGET_FILE="$(basename "$TARGET_FILE")"

COUNT=0
while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
do
TARGET_FILE="$(readlink "$TARGET_FILE")"
cd $(dirname "$TARGET_FILE")
TARGET_FILE="$(basename $TARGET_FILE)"
COUNT=$(($COUNT + 1))
done

echo "$(pwd -P)/"$TARGET_FILE""
)
}

bin=$(dirname $(realpath $0))
basedir=$(dirname "$bin")
if [[ -d "$basedir/lib" ]]
Expand Down

0 comments on commit d0d4908

Please sign in to comment.