Skip to content

Commit 05c6b92

Browse files
committed
Better symlink resolution - works OSX and Linux
1 parent 9f0d26d commit 05c6b92

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packaging/transrate

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22
set -e
33

44
# Figure out where this script is located.
5-
SELFSCRIPT="`readlink -f \"$0\"`"
5+
THIS_FILE=$0
6+
7+
cd `dirname $THIS_FILE`
8+
THIS_FILE=`basename $THIS_FILE`
9+
10+
# Iterate down a (possible) chain of symlinks
11+
# Compute the canonicalized name by finding the physical path
12+
# for the directory we're in and appending the target file.
13+
while [ -L "$THIS_FILE" ]
14+
do
15+
THIS_FILE=`readlink $THIS_FILE`
16+
cd `dirname $THIS_FILE`
17+
THIS_FILE=`basename $THIS_FILE`
18+
done
19+
20+
SELFSCRIPT=$PHYS_DIR/$THIS_FILE
621
SELFDIR="`dirname \"$SELFSCRIPT\"`"
722
SELFDIR="`cd \"$SELFDIR\" && pwd`"
823

0 commit comments

Comments
 (0)