Skip to content

Commit

Permalink
RelativeLink.sh: cd to "$(dirname $0)" if it exists
Browse files Browse the repository at this point in the history
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 8958863
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions RelativeLink.sh
Expand Up @@ -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"
Expand Down

0 comments on commit 8958863

Please sign in to comment.