Then something like this? (untested)
#!/bin/sh path_prepend_first () { export PATH="$1:$PATH" }
If $PATH is empty at the time this is function is executed, you will end up with : at the end of your $PATH, which is equivalent to "." and is marginally better at the end of the PATH than at the beginning, but not by much.
if ! archlinux-java get | grep -q java-11- then path_prepend_first /usr/lib/jvm/java-11-*/jre/bin fi exec /path/to/application "$@"
Kind of useless use of grep.
#!/bin/sh
# this comes from /etc/profile
prependpath () {
case ":$PATH:" in
*:"$1":*)
;;
*)
export PATH="$1${PATH:+:$PATH}"
esac
}
case $(archlinux-java get) in
*java-11*)
;;
*)
prependpath /usr/lib/jvm/java-11-*/jre/bin
esac
exec /path/to/application "$@"
#!/bin/sh
path_prepend_first () {
export PATH="$1:$PATH"
}
if ! archlinux-java get | grep -q java-11-
then
path_prepend_first /usr/lib/jvm/java-11-*/jre/bin
fi
exec /path/to/application "$@"