declare -a JARPATHS=()
if [ -e "${GETDOWNTXT}" ]; then
# always check grep and sed regexes on macos -- they're not the same
- for JAR in $(grep -e '^code\s*=\s*' "${GETDOWNTXT}" | sed -e 's/^code\s*=\s*//;'); do
+for JAR in $(grep -e '^code[[:space:]]*=[[:space:]]*' "${GETDOWNTXT}" | while read -r line; do echo $line | sed -E -e 's/code[[:space:]]*=[[:space:]]*//;'; done);
+ do
[ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH}:"
CLASSPATH="${CLASSPATH}${APPDIR}/${JAR}"
JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${JAR}" )
# WINDOWS ONLY (Cygwin or WSL)
# change paths for Cygwin or Windows Subsystem for Linux (WSL)
-if [ "${ISMACOS}" != 1 ]; then # macos doesn't like uname -o, best to avoid
+if [ "${ISMACOS}" != 1 ]; then # older macos doesn't like uname -o, best to avoid
if [ "$(uname -o)" = "Cygwin" ]; then
# CYGWIN
- echo "When using relative paths in args within Cygwin, please start with './' or '../'" >&2
CLASSPATH=$(cygpath -pw "${CLASSPATH}")
# now for some arg paths fun. only translating paths starting with './', '../', '/' or '~'
ARGS=()
ARGS=( "${ARGS[@]}" "${ARG}" )
fi
done
- elif uname -r | grep Microsoft >/dev/null; then
+ elif uname -r | grep -i microsoft | grep -i wsl >/dev/null; then
# WSL
- echo "When using relative paths in args within WSL, please start with './' or '../'" >&2
CLASSPATH=""
for JARPATH in "${JARPATHS[@]}"; do
[ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH};"
fi
fi
+# get console width -- three ways to try, just in case
+if command -v tput 2>&1 >/dev/null; then
+ COLUMNS=$(tput cols) 2>/dev/null
+elif command -v stty 2>&1 >/dev/null; then
+ COLUMNS=$(stty size | cut -d" " -f2) 2>/dev/null
+elif command -v resize 2>&1 >/dev/null; then
+ COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null
+fi
+JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" )
+JVMARGS=( "${JVMARGS[@]}" "-Dgetdownappdir=${APPDIR}" )
+
# Is there a bundled Java? If not just try one in the PATH (do need .exe in WSL)
if [ \! -e "${JAVA}" ]; then
JAVA=$SYSJAVA
echo "Cannot find bundled java, using system ${JAVA} and hoping for the best!" >&2
fi
-# check to see if $1 is set and is not start of other cli args
-OPEN=""
-if [ -n "${ARG1}" -a "${ARG1}" = "${ARG1#-}" -a "${ARG1}" != "open" ]; then
- # first argument exists and does not start with a "-" and is not "open"
- OPEN="-open"
-fi
-
-# don't quote $OPEN (don't want it accidentally mistaken as an empty string arg!)
-"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher ${OPEN} "${ARGS[@]}"
+"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher "${ARGS[@]}"