Skip to content

Commit

Permalink
Doctor check for JENV_LOADED environment variable
Browse files Browse the repository at this point in the history
* Users may not have jenv init in their shell profile, but may load it
* indirectly in another manner, so check for JENV_LOADED=1 in
* environment.

* Fix misspelling of "correctly"
  • Loading branch information
schlosna committed Aug 29, 2014
1 parent c162efd commit dacf5d4
Showing 1 changed file with 27 additions and 33 deletions.
60 changes: 27 additions & 33 deletions libexec/jenv-doctor
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function cinfo() {
RESET='\033[00;00m' # normal white
echo -e "${COLOR}[OK]\t$*${RESET}"
}

# Display colorized warning output
function cwarn() {
COLOR='\033[01;31m' # bold red
Expand All @@ -26,16 +26,16 @@ function cfix() {
}

set -e
[ -n "$JENV_DEBUG" ] && set -x
[ -n "$JENV_DEBUG" ] && set -x

exportedValues=""

exportVariable(){
exportVariable(){
echo $exportedValues
# echo $1, $2, $3
# echo $1, $2, $3
exportedValues="$exportedValues:$1"
export $1="$2 $3 $4 $5 $6 $7 $8 $9"

}

# Provide jenv completions
Expand All @@ -44,7 +44,7 @@ echo $exportedValues
#fi


if [[ ! -z "$JAVA_HOME" ]] ; then
if [[ ! -z "$JAVA_HOME" ]] ; then
cwarn "JAVA_HOME variable already set, scripts that use it directly could not use java version set by jenv"
else
cinfo "No JAVA_HOME set"
Expand All @@ -55,44 +55,38 @@ JAVA_BIN=`command -v java`
EXPECTED_JAVA="$JENV_ROOT/shims/java"




if [ "$EXPECTED_JAVA" = "$JAVA_BIN" ] ; then
cinfo "Java binaries in path are jenv shims"
cinfo "Java binaries in path are jenv shims"
else
cwarn "java binary in path is not he the jenv shims"
cwarn "Please check your path"
cfix "PATH : $PATH"

fi

shell="$(basename "$SHELL")"


case "$shell" in
bash )
profile="$HOME/.bash_profile"
;;
zsh )
profile="$HOME/.zshrc"
;;
ksh )
profile="$HOME/.profile"
;;
* )
profile='your profile'
;;
esac

if grep --quiet "jenv init" $profile; then
cinfo "Jenv is correlly loaded"
if [ "$JENV_LOADED" = "1" ]; then
cinfo "Jenv is correctly loaded"

else
shell="$(basename "$SHELL")"

case "$shell" in
bash )
profile="$HOME/.bash_profile"
;;
zsh )
profile="$HOME/.zshrc"
;;
ksh )
profile="$HOME/.profile"
;;
* )
profile='your profile'
;;
esac

cwarn "Jenv is not loaded in your $shell"
cwarn 'To fix : \tcat eval "$(jenv init -)" >>' $profile

fi




0 comments on commit dacf5d4

Please sign in to comment.