summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sci-mathematics/geogebra-bin/files/geogebra.sh')
-rw-r--r--sci-mathematics/geogebra-bin/files/geogebra.sh33
1 files changed, 21 insertions, 12 deletions
diff --git a/sci-mathematics/geogebra-bin/files/geogebra.sh b/sci-mathematics/geogebra-bin/files/geogebra.sh
index 652563aa47f..b0f941e8a46 100644
--- a/sci-mathematics/geogebra-bin/files/geogebra.sh
+++ b/sci-mathematics/geogebra-bin/files/geogebra.sh
@@ -1,23 +1,32 @@
#!@GENTOO_PORTAGE_EPREFIX@/bin/bash
+set -euo pipefail
+IFS=$'\n\t'
+
main() {
- local JAVACMD
- # prefer openjdk-8 over 11
- local j8="$(java-config --select-vm openjdk-8 -J)"
- local j11="$(java-config --select-vm openjdk-11 -J)"
+ local j8 j11 jcmd
+ j8="$(java-config --select-vm openjdk-8 -J 2> /dev/null || true)"
+ j11="$(java-config --select-vm openjdk-11 -J 2> /dev/null || true)"
- if [[ -f $(dirname ${j8:-/})/../jre/lib/javafx.properties ]]; then
- JAVACMD="${j8}"
- elif [[ -f $(dirname ${j11:-/})/../lib/javafx.properties ]]; then
- JAVACMD="${j11}"
+ if [[ -f "$(dirname "${j8:-/}")/../jre/lib/javafx.properties" ]]; then
+ jcmd="${j8}"
+ elif [[ -f "$(dirname "${j11:-/}")/../lib/javafx.properties" ]]; then
+ jcmd="${j11}"
+ elif [[ -f @GENTOO_PORTAGE_EPREFIX@/usr/lib64/openjdk-11/lib/javafx.properties ]]; then
+ jcmd="@GENTOO_PORTAGE_EPREFIX@/usr/lib64/openjdk-11/bin/java"
+ elif [[ -f @GENTOO_PORTAGE_EPREFIX@/usr/lib/openjdk-11/lib/javafx.properties ]]; then
+ jcmd="@GENTOO_PORTAGE_EPREFIX@/usr/lib/openjdk-11/bin/java"
else
- echo "openjdk[javafx] not found!" 1>&2
+ echo "dev-java/openjdk[javafx] not found!" 1>&2
+ exit 1
+ fi
+
+ if [[ ! -x "${jcmd}" ]]; then
+ echo "${jcmd} not executable!" 1>&2
exit 1
fi
- echo "using ${JAVACMD}"
- export JAVACMD
- exec "@GENTOO_PORTAGE_EPREFIX@/opt/geogebra/geogebra" "${@}"
+ env JAVACMD="${jcmd}" "@GENTOO_PORTAGE_EPREFIX@/opt/geogebra/geogebra" "${@}"
}
main "$@"