Don't need readlink to find BASE_DIR anymore

This commit is contained in:
T. Joseph Carter 2015-02-16 21:06:42 -08:00
parent 662b420d76
commit 5d80de96fc

View File

@ -1,26 +1,18 @@
#! /usr/bin/env bash
# vim: set ts=3 sw=3 noet ft=sh : bash
# BSDs don't have readlink -f
read_link()
{
TARGET_FILE="${1}"
cd "`dirname "${TARGET_FILE}"`"
TARGET_FILE="`basename "${TARGET_FILE}"`"
SCRIPT="${0#./}"
BASE_DIR="${SCRIPT%/*}"
WORKDIR=$PWD
while [ -L "${TARGET_FILE}" ]; do
TARGET_FILE="`readlink "${TARGET_FILE}"`"
cd "`dirname "${TARGET_FILE}"`"
TARGET_FILE="`basename "${TARGET_FILE}"`"
done
PHYS_DIR="`pwd -P`"
RESULT="${PHYS_DIR}/${TARGET_FILE}"
echo ${RESULT}
}
SCRIPT="`read_link "$0"`"
BASE_DIR="`dirname "${SCRIPT}"`"
WORKDIR="`pwd`"
if [ "$BASE_DIR" = "$SCRIPT" ]; then
BASE_DIR="$WORKDIR"
else
if [[ "$0" != /* ]]; then
# Make the path absolute
BASE_DIR="$WORKDIR/$BASE_DIR"
fi
fi
. ${BASE_DIR}/libretro-config.sh