Manage your Java environment
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

59 lines
1.1 KiB

#!/usr/bin/env bash
#
# Summary: Show information about which command will be executed
#
# Usage: jenv info <command>
#
set -e
[ -n "$JENV_DEBUG" ] && set -x
exportedValues=""
exportVariable(){
exportedValues="$exportedValues:$1"
export "$1"="$2"
}
# Provide jenv completions
if [ "$1" = "--complete" ]; then
exec jenv shims --short
fi
JENV_VERSION="$(jenv-version-name)"
export JENV_VERSION
JENV_OPTIONS="$(jenv-options)"
export JENV_OPTIONS
JENV_COMMAND="$1"
if [ "$JENV_VERSION" != "system" ]; then
export JAVA_HOME="$JENV_ROOT/versions/$JENV_VERSION"
fi
JENV_COMMAND_PATH="$(jenv-which "$JENV_COMMAND")"
JENV_BIN_PATH="${JENV_COMMAND_PATH%/*}"
for script in $(jenv-hooks exec); do
# shellcheck source=/dev/null
source "$script"
done
shift 1
if [ "$JENV_VERSION" != "system" ]; then
export PATH="${JENV_BIN_PATH}:${PATH}"
fi
echo "Jenv will exec : $JENV_COMMAND_PATH $JENV_OPTIONS $*"
echo "Exported variables :"
echo " JAVA_HOME=$JAVA_HOME"
while IFS=':' read -ra ADDR; do
for i in "${ADDR[@]}"; do
if [ -n "$i" ]; then
echo " $i=${!i}"
fi
done
done <<< "$exportedValues"