5 # this whole next part is because there's no readlink -f in Darwin
11 MAX=100 # just in case we end up in a loop
13 while [ "${C}" -lt "${MAX}" -a "${FILE}" != "${PREVFILE}" -a "${FOUND}" -ne 1 ]; do
15 FILE="$(readlink "${FILE}")"
16 if [ -z "${FILE}" ]; then
17 # the readlink is empty means we've arrived at the script, let's canonicalize with pwd
18 FILE="$(cd "$(dirname "${PREVFILE}")" &> /dev/null && pwd -P)"/"$(basename "${PREVFILE}")"
20 elif [ "${FILE#/}" = "${FILE}" ]; then
21 # FILE is not an absolute path link, we need to add the relative path to the previous dir
22 FILE="$(dirname "${PREVFILE}")/${FILE}"
26 if [ "${FOUND}" -ne 1 ]; then
27 echo "Could not determine path to actual file '$(basename "${FINDFILE}")'" >&2
33 DIR="$(dirname "$(readlinkf "$0")")"
34 APP="${DIR%.app/Contents/*}".app
36 if [ "${APP}" = "${APP%.app}" ]; then
37 echo "Could not find Jalview.app dir" >&2
41 # check to see if $1 is set and is not start of other cli set args
43 if [ -n "${ARG1}" -a "${ARG1}" = "${ARG1#-}" -a "${ARG1}" != "open" ]; then
44 # first argument exists and does not start with a "-" and is not "open"
48 APPDIR="${APP}/Contents/Resources/app"
49 JAVA="${APPDIR}/jre/Contents/Home/bin/java"
50 GETDOWNTXT="${APPDIR}/getdown.txt"
52 if [ -e "${GETDOWNTXT}" ]; then
53 # always check grep and sed regexes on macOS -- they're not the same
54 for JAR in $(grep -e '^code\s*=\s*' "${GETDOWNTXT}" | sed -e 's/^code\s*=\s*//;'); do
55 [ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH}:"
56 CLASSPATH="${CLASSPATH}${APPDIR}/${JAR}"
59 echo "Cannot find getdown.txt" >&2
63 if [ \! -e "${JAVA}" ]; then
64 echo "Cannot find bundled java, using system and hoping for the best!" >&2
69 "${JAVA}" -Xdock:icon="${APPDIR}"/resource/jalview_logo.png -cp "${CLASSPATH}" jalview.bin.Launcher ${OPEN} "$@"