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

[or-cvs] r23017: {torbrowser} RelativeLink.sh: cd to "$(dirname $0)" if it exists This scr (torbrowser/trunk/src/RelativeLink)



Author: erinn
Date: 2010-08-22 10:34:45 +0000 (Sun, 22 Aug 2010)
New Revision: 23017

Modified:
   torbrowser/trunk/src/RelativeLink/RelativeLink.sh
Log:
RelativeLink.sh: cd to "$(dirname $0)" if it exists

This script relies on App et al existing in the CWD. Try to find out
where it is and cd to it.

This makes it possible to start the script via e.g. GNOME launchers,
which don't change the CWD.

Signed-off-by: ?\195?\134var Arnfj?\195?\182r?\195?\176 Bjarmason <avarab@xxxxxxxxx>

Modified: torbrowser/trunk/src/RelativeLink/RelativeLink.sh
===================================================================
--- torbrowser/trunk/src/RelativeLink/RelativeLink.sh	2010-08-22 10:34:40 UTC (rev 23016)
+++ torbrowser/trunk/src/RelativeLink/RelativeLink.sh	2010-08-22 10:34:45 UTC (rev 23017)
@@ -14,6 +14,11 @@
 	printf "\nDebug enabled.\n\n"
 fi
 
+# Try to be agnostic to where we're being started from, chdir to where
+# the script is.
+mydir="$(dirname $0)"
+test -d "$mydir" && cd "$mydir"
+
 # If ${PWD} results in a zero length HOME, we can try something else...
 if [ ! "${PWD}" ]; then
 	# "hacking around some braindamage"