Skip to content
Permalink
Browse files
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: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  • Loading branch information
avar committed Aug 14, 2010
1 parent feb7e11 commit 895886337f907879598982b9ce104b9b8f3b2fbf
Showing with 5 additions and 0 deletions.
  1. +5 −0 RelativeLink.sh
@@ -14,6 +14,11 @@ if [ $1 ]; then
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"

0 comments on commit 8958863

Please sign in to comment.