JAL-4160 JAL-3830 Improvements to the jalview.sh bash script especially when not...
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 16 Aug 2023 16:48:00 +0000 (17:48 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 16 Aug 2023 16:48:00 +0000 (17:48 +0100)
utils/getdown/bin/jalview.sh

index 07fd6ed..371bfcd 100755 (executable)
@@ -38,13 +38,35 @@ fi
 
 # check for headless mode
 HEADLESS=0
+GUI=0
+HELP=0
+DEBUG=0
 for ARG in "${@}"; do
-  if [ "${ARG}" = "--headless" ]; then
+  case "${ARG}" in
+    "--headless")
+      HEADLESS=1
+      ;;
+    "--help")
+      HELP=1
+      ;;
+    --help-*)
+      HELP=1
+      ;;
+    "--gui")
+      GUI=1
+      ;;
+    "--debug")
+      DEBUG=1
+      ;;
+  esac
+  
+  if [ "${HELP}" = 1 ]; then
+    # --help takes precedence
     HEADLESS=1
-  elif [ "${ARG}" = "--gui" ]; then
+    GUI=0
+  elif [ "${GUI}" = 1 ]; then
     # --gui takes precedence over --headless
     HEADLESS=0
-    break
   fi
 done
 
@@ -54,12 +76,7 @@ declare -a JVMARGS=()
 if [ "${ISMACOS}" = 1 ]; then
 # MACOS ONLY
   DIR="$(dirname "$(readlinkf "$0")")"
-  APP="${DIR%.app/Contents/*}".app
-  if [ "${APP}" = "${APP%.app}" ]; then
-    echo "Could not find Jalview.app" >&2
-    exit 2
-  fi
-  APPDIR="${APP}/Contents/Resources/app"
+  APPDIR="${DIR%/bin}"
   JAVA="${APPDIR}/jre/Contents/Home/bin/java"
   JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" )
 else
@@ -148,4 +165,8 @@ if [ \! -e "${JAVA}" ]; then
   echo "Cannot find bundled java, using system ${JAVA} and hoping for the best!" >&2
 fi
 
+if [ "${DEBUG}" = 1 ]; then
+ echo Shell running: \""${JAVA}"\" \""${JVMARGS[@]}"\" -cp \""${CLASSPATH}"\" jalview.bin.Launcher "${ARGS[@]}"
+fi
+
 "${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher "${ARGS[@]}"