Skip to content

Commit

Permalink
make launcher suitable for mac environment
Browse files Browse the repository at this point in the history
readlink -f doesn't work on mac, so i used code salvaged from the internets to simulate the functionality on mac
  • Loading branch information
widelec committed Mar 10, 2014
1 parent 79b30f3 commit a1ae1b8
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions cataclysm-launcher
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
#!/bin/sh
DIR=$(dirname "$(readlink -f "$0")")
BIN=$(basename "$0")
TARGET_FILE=$0

cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`

# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=`readlink $TARGET_FILE`
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
done

# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR=`pwd -P`
RESULT=$PHYS_DIR/$TARGET_FILE
echo $RESULT

DIR=$(dirname $RESULT)
BIN=$(basename $RESULT)

cd "$DIR" || exit $?

# If name does not match a binary or is this same script, find the right one
if [ ! -f "$BIN" ] || [ "$BIN" = "$(basename "$(readlink -f "$0")")" ]
if [ ! -f "$BIN" ] || [ "$BIN" = "$(basename $RESULT)" ]
then
BIN=
for bin in cataclysm-tiles cataclysm
Expand Down

0 comments on commit a1ae1b8

Please sign in to comment.