[tor-commits] [torbrowser/maint-2.2] [2525 Linux] Handle being launched using a symlink
erinn at torproject.org
erinn at torproject.org
Sun Oct 23 23:18:56 UTC 2011
commit 7bf12712a8aa2556fdb023c69bbf51d727a17b90
Author: Robert Ransom <rransom.8774 at gmail.com>
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...
More information about the tor-commits
mailing list