[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbrowser/maint-2.2] [2525 Linux] Handle being launched using a symlink



commit 7bf12712a8aa2556fdb023c69bbf51d727a17b90
Author: Robert Ransom <rransom.8774@xxxxxxxxx>
Date:   Wed Aug 24 03:10:31 2011 -0400

    [2525 Linux] Handle being launched using a symlink
---
 src/RelativeLink/RelativeLink.sh |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/RelativeLink/RelativeLink.sh b/src/RelativeLink/RelativeLink.sh
index fd8ed0c..1321e0c 100755
--- a/src/RelativeLink/RelativeLink.sh
+++ b/src/RelativeLink/RelativeLink.sh
@@ -103,9 +103,24 @@ if [ -z "$XAUTHORITY" ]; then
 	export XAUTHORITY
 fi
 
+# If this script is being run through a symlink, we need to know where
+# in the filesystem the script itself is, not where the symlink is.
+myname="$0"
+while [ -L "$myname" ]; do
+	# XXX readlink is not POSIX, but is present in GNU coreutils
+	# and on FreeBSD.  Unfortunately, the -f option (which follows
+	# a whole chain of symlinks until it reaches a non-symlink
+	# path name) is a GNUism, so we can't safely use it.  (Using
+	# it would be rude to FreeBSD users who currently have no
+	# other officially supported choice than TBB for Linux, and
+	# might even break compatibility with older versions of the
+	# GNU utility.)
+	myname="`readlink -n "$myname"`"
+done
+
 # Try to be agnostic to where we're being started from, chdir to where
 # the script is.
-mydir="$(dirname "$0")"
+mydir="$(dirname "$myname")"
 test -d "$mydir" && cd "$mydir"
 
 # If ${PWD} results in a zero length HOME, we can try something else...



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits