Browse Source

Quote all references to path related variables (and variables that use it) to avoid word splitting.

This avoids errors where path contains spaces (e.g. `$HOME/Library/Application Support/jenv`).
pull/452/head
gouvinb 5 months ago
parent
commit
5278c64b69
  1. 4
      available-plugins/ant/etc/jenv.d/rehash/ant.bash
  2. 9
      available-plugins/export/etc/jenv.d/init/export_jenv_hook.bash
  3. 9
      available-plugins/export/etc/jenv.d/init/export_jenv_hook.zsh
  4. 4
      available-plugins/golo/etc/jenv.d/rehash/golo.bash
  5. 4
      available-plugins/gradle/etc/jenv.d/rehash/gradle.bash
  6. 4
      available-plugins/grails/etc/jenv.d/rehash/grails.bash
  7. 4
      available-plugins/groovy/etc/jenv.d/rehash/groovy.bash
  8. 4
      available-plugins/lein/etc/jenv.d/rehash/lein.bash
  9. 4
      available-plugins/maven/etc/jenv.d/rehash/maven.bash
  10. 2
      available-plugins/sbt/etc/jenv.d/exec/sbt-before.bash
  11. 4
      available-plugins/sbt/etc/jenv.d/rehash/sbt.bash
  12. 4
      available-plugins/scala/etc/jenv.d/rehash/scala.bash
  13. 4
      available-plugins/springboot/etc/jenv.d/rehash/springboot.bash
  14. 4
      available-plugins/vlt/etc/jenv.d/rehash/vlt.bash
  15. 26
      libexec/jenv
  16. 6
      libexec/jenv-add
  17. 6
      libexec/jenv-hooks
  18. 4
      libexec/jenv-plugins
  19. 2
      libexec/jenv-refresh-plugins
  20. 4
      libexec/jenv-refresh-versions
  21. 6
      libexec/jenv-versions

4
available-plugins/ant/etc/jenv.d/rehash/ant.bash

@ -1,11 +1,11 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
ANT_BIN="$(command -v "ant" || true)" ANT_BIN="$(command -v "ant" || true)"
PATH=$backuppath PATH="$backuppath"
#echo "make shims $MAVEN_BIN" #echo "make shims $MAVEN_BIN"
make_shims "$ANT_BIN" make_shims "$ANT_BIN"

9
available-plugins/export/etc/jenv.d/init/export_jenv_hook.bash

@ -1,16 +1,15 @@
#export #export
_jenv_export_hook() { _jenv_export_hook() {
export JAVA_HOME=$(jenv javahome 2>/dev/null) export JAVA_HOME="$(jenv javahome 2>/dev/null)"
export JENV_FORCEJAVAHOME=true export JENV_FORCEJAVAHOME=true
if [ -e "$JAVA_HOME/bin/javac" ] if [ -e "$JAVA_HOME/bin/javac" ]; then
then
export JDK_HOME="$JAVA_HOME" export JDK_HOME="$JAVA_HOME"
export JENV_FORCEJDKHOME=true export JENV_FORCEJDKHOME=true
fi fi
} }
if ! [[ "$PROMPT_COMMAND" =~ _jenv_export_hook ]]; then if ! [[ "$PROMPT_COMMAND" =~ _jenv_export_hook ]]; then
PROMPT_COMMAND="_jenv_export_hook;$PROMPT_COMMAND"; PROMPT_COMMAND="_jenv_export_hook;$PROMPT_COMMAND";

9
available-plugins/export/etc/jenv.d/init/export_jenv_hook.zsh

@ -1,15 +1,14 @@
#export #export
_jenv_export_hook() { _jenv_export_hook() {
export JAVA_HOME=$(jenv javahome 2>/dev/null) export JAVA_HOME="$(jenv javahome 2>/dev/null)"
export JENV_FORCEJAVAHOME=true export JENV_FORCEJAVAHOME=true
if [ -e "$JAVA_HOME/bin/javac" ] if [ -e "$JAVA_HOME/bin/javac" ]; then
then
export JDK_HOME="$JAVA_HOME" export JDK_HOME="$JAVA_HOME"
export JENV_FORCEJDKHOME=true export JENV_FORCEJDKHOME=true
fi fi
} }
#echo "configure export plugin for ZSH" #echo "configure export plugin for ZSH"
function install_hook { function install_hook {

4
available-plugins/golo/etc/jenv.d/rehash/golo.bash

@ -1,6 +1,6 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
GOLO_BIN="$(command -v "golo" || true)" GOLO_BIN="$(command -v "golo" || true)"
@ -8,7 +8,7 @@ GOLOC_BIN="$(command -v "goloc" || true)"
GOLOGOLO_BIN="$(command -v "gologolo" || true)" GOLOGOLO_BIN="$(command -v "gologolo" || true)"
PATH=$backuppath PATH="$backuppath"
make_shims "$GOLOGOLO_BIN" make_shims "$GOLOGOLO_BIN"
make_shims "$GOLOC_BIN" make_shims "$GOLOC_BIN"

4
available-plugins/gradle/etc/jenv.d/rehash/gradle.bash

@ -1,11 +1,11 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
GRADLE_BIN="$(command -v "gradle" || true)" GRADLE_BIN="$(command -v "gradle" || true)"
PATH=$backuppath PATH="$backuppath"
#echo "make shims $MAVEN_BIN" #echo "make shims $MAVEN_BIN"
make_shims "$GRADLE_BIN" make_shims "$GRADLE_BIN"

4
available-plugins/grails/etc/jenv.d/rehash/grails.bash

@ -1,6 +1,6 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
GRAILS_BIN="$(command -v "grails" || true)" GRAILS_BIN="$(command -v "grails" || true)"
@ -9,7 +9,7 @@ make_shims "$GRAILS_BIN"
GRAILS_DEBUG="$(command -v "grails-debug" || true)" GRAILS_DEBUG="$(command -v "grails-debug" || true)"
make_shims "$GRAILS_DEBUG" make_shims "$GRAILS_DEBUG"
PATH=$backuppath PATH="$backuppath"

4
available-plugins/groovy/etc/jenv.d/rehash/groovy.bash

@ -1,6 +1,6 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
GROOVY_BIN="$(command -v "groovy" || true)" GROOVY_BIN="$(command -v "groovy" || true)"
@ -16,7 +16,7 @@ GROOVY_BIN="$(command -v "groovysh" || true)"
make_shims "$GROOVY_BIN" make_shims "$GROOVY_BIN"
PATH=$backuppath PATH="$backuppath"

4
available-plugins/lein/etc/jenv.d/rehash/lein.bash

@ -1,13 +1,13 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
LEIN_BIN="$(command -v "lein" || true)" LEIN_BIN="$(command -v "lein" || true)"
PATH=$backuppath PATH="$backuppath"
make_shims "$LEIN_BIN" make_shims "$LEIN_BIN"

4
available-plugins/maven/etc/jenv.d/rehash/maven.bash

@ -1,13 +1,13 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
MAVEN_BIN="$(command -v "mvn" || true)" MAVEN_BIN="$(command -v "mvn" || true)"
MAVEN_DEBUG="$(command -v "mvnDebug" || true)" MAVEN_DEBUG="$(command -v "mvnDebug" || true)"
PATH=$backuppath PATH="$backuppath"
make_shims "$MAVEN_BIN" make_shims "$MAVEN_BIN"
make_shims "$MAVEN_DEBUG" make_shims "$MAVEN_DEBUG"

2
available-plugins/sbt/etc/jenv.d/exec/sbt-before.bash

@ -7,5 +7,5 @@ if [ "$1" = "sbt" ]; then
fi fi
unset JENV_OPTIONS unset JENV_OPTIONS
fi fi
JENV_OPTIONS="$JENV_OPTIONS -java-home $JAVA_HOME" JENV_OPTIONS="$JENV_OPTIONS -java-home '$JAVA_HOME'"
fi fi

4
available-plugins/sbt/etc/jenv.d/rehash/sbt.bash

@ -1,12 +1,12 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
SBT_BIN="$(command -v "sbt" || true)" SBT_BIN="$(command -v "sbt" || true)"
PATH=$backuppath PATH="$backuppath"
make_shims "$SBT_BIN" make_shims "$SBT_BIN"

4
available-plugins/scala/etc/jenv.d/rehash/scala.bash

@ -1,6 +1,6 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
SCALA_BIN="$(command -v "scala" || true)" SCALA_BIN="$(command -v "scala" || true)"
@ -8,7 +8,7 @@ SCALAC_BIN="$(command -v "scalac" || true)"
FSC_BIN="$(command -v "fsc" || true)" FSC_BIN="$(command -v "fsc" || true)"
PATH=$backuppath PATH="$backuppath"
make_shims "$SCALA_BIN" make_shims "$SCALA_BIN"
make_shims "$SCALAC_BIN" make_shims "$SCALAC_BIN"

4
available-plugins/springboot/etc/jenv.d/rehash/springboot.bash

@ -1,6 +1,6 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
GRAILS_BIN="$(command -v "spring" || true)" GRAILS_BIN="$(command -v "spring" || true)"
@ -8,7 +8,7 @@ make_shims "$GRAILS_BIN"
PATH=$backuppath PATH="$backuppath"

4
available-plugins/vlt/etc/jenv.d/rehash/vlt.bash

@ -1,9 +1,9 @@
backuppath=$PATH backuppath="$PATH"
PATH="$(remove_from_path "${JENV_ROOT}/shims")" PATH="$(remove_from_path "${JENV_ROOT}/shims")"
VLT_BIN="$(command -v "vlt" || true)" VLT_BIN="$(command -v "vlt" || true)"
make_shims "$VLT_BIN" make_shims "$VLT_BIN"
PATH=$backuppath PATH="$backuppath"

26
libexec/jenv

@ -22,23 +22,23 @@ abs_dirname() {
resolvepath() { resolvepath() {
local cwd="$(pwd)" local cwd="$(pwd)"
cd $1 cd "$1"
echo "$(pwd)" echo "$(pwd)"
cd "$cwd" cd "$cwd"
} }
samedir() { samedir() {
if [ -d $1 ] && [ -d $2 ]; then if [ -d "$1" ] && [ -d "$2" ]; then
local path1="$(resolvepath $1)" local path1="$(resolvepath "$1")"
local path2="$(resolvepath $2)" local path2="$(resolvepath "$2")"
if [ $path1 == $path2 ]; then if [ "$path1" == "$path2" ]; then
return 0; return 0;
else else
return 1; return 1;
fi
fi fi
fi return 0;
return 0;
} }
if [ -z "${JENV_ROOT}" ]; then if [ -z "${JENV_ROOT}" ]; then
@ -70,7 +70,7 @@ shopt -s nullglob
bin_path="$(abs_dirname "$0")" bin_path="$(abs_dirname "$0")"
if ! samedir "${JENV_ROOT}" "$bin_path/../" ; then if ! samedir "${JENV_ROOT}" "$bin_path/../" ; then
JENV_INSTALL_DIR=$(resolvepath "$bin_path/../") JENV_INSTALL_DIR="$(resolvepath "$bin_path/../")"
else else
JENV_INSTALL_DIR="$JENV_ROOT" JENV_INSTALL_DIR="$JENV_ROOT"
fi fi
@ -91,7 +91,7 @@ for plugin_hook in "${JENV_ROOT}/plugins/"*/etc/jenv.d; do
done done
export JENV_HOOK_PATH=$hook_path export JENV_HOOK_PATH="$hook_path"

6
libexec/jenv-add

@ -13,7 +13,7 @@ fi
if [ "$1" = "--complete" ]; then if [ "$1" = "--complete" ]; then
echo "--skip-existing" echo "--skip-existing"
for d in ${!#}*; do for d in ${!#}*; do
[[ -d "$d" ]] && echo $d/ [[ -d "$d" ]] && echo "$d/"
done done
exit exit
fi fi
@ -59,7 +59,7 @@ function add_alias_check(){
function add_alias(){ function add_alias(){
cd "${JENV_JAVAPATH}" cd "${JENV_JAVAPATH}"
JENV_JAVAPATH=$PWD JENV_JAVAPATH="$PWD"
cd - 2>&1 > /dev/null cd - 2>&1 > /dev/null
mkdir -p "${JENV_ROOT}/versions" mkdir -p "${JENV_ROOT}/versions"
ln -s "${JENV_JAVAPATH}" "${JENV_ROOT}/versions/$1" ln -s "${JENV_JAVAPATH}" "${JENV_ROOT}/versions/$1"
@ -122,7 +122,7 @@ if [ -f "${JENV_JAVAPATH}/bin/java" ]; then
if [ $JAVA_PROVIDER=="sap" ]; then if [ $JAVA_PROVIDER=="sap" ]; then
JAVA_PLATFORM="64" JAVA_PLATFORM="64"
else else
if ${JENV_JAVAPATH}/bin/java -version 2>&1 | grep -q "64-Bit"; then if "${JENV_JAVAPATH}/bin/java" -version 2>&1 | grep -q "64-Bit"; then
JAVA_PLATFORM="64" JAVA_PLATFORM="64"
else else
JAVA_PLATFORM="32" JAVA_PLATFORM="32"

6
libexec/jenv-hooks

@ -49,17 +49,17 @@ for path in ${JENV_HOOK_PATH//:/$'\n'}; do
case "$shell" in case "$shell" in
bash ) bash )
for script in $path/"$JENV_COMMAND"/*.bash; do for script in $path/"$JENV_COMMAND"/*.bash; do
echo $(realpath $script) echo $(realpath "$script")
done done
;; ;;
zsh ) zsh )
for script in $path/"$JENV_COMMAND"/*.zsh; do for script in $path/"$JENV_COMMAND"/*.zsh; do
echo $(realpath $script) echo $(realpath "$script")
done done
;; ;;
fish ) fish )
for script in $path/"$JENV_COMMAND"/*.fish; do for script in $path/"$JENV_COMMAND"/*.fish; do
echo $(realpath $script) echo $(realpath "$script")
done done
;; ;;
esac esac

4
libexec/jenv-plugins

@ -21,7 +21,7 @@ samedir() {
local path1="$(resolvepath $1)" local path1="$(resolvepath $1)"
local path2="$(resolvepath $2)" local path2="$(resolvepath $2)"
if [ $path1 == $path2 ]; then if [ "$path1" == "$path2" ]; then
return 0; return 0;
else else
return 1; return 1;
@ -30,7 +30,7 @@ samedir() {
resolvepath() { resolvepath() {
local cwd="$(pwd)" local cwd="$(pwd)"
cd $1 cd "$1"
echo "$(pwd)" echo "$(pwd)"
cd "$cwd" cd "$cwd"
} }

2
libexec/jenv-refresh-plugins

@ -32,7 +32,7 @@ if [ ! "$lastVersion" == "$currentVersion" ] || [ $FORCE_REFRESH == "1" ]; then
echo "jenv has been updated, process to refresh plugin links" echo "jenv has been updated, process to refresh plugin links"
for path in "${JENV_ROOT}/plugins/"*; do for path in "${JENV_ROOT}/plugins/"*; do
if [ -L "$path" ]; then if [ -L "$path" ]; then
pluginName=$(basename $path) pluginName=$(basename "$path")
echo "Refresh plugin $pluginName" echo "Refresh plugin $pluginName"
ln -sfn "${JENV_INSTALL_DIR}/available-plugins/$pluginName" "${JENV_ROOT}/plugins/$pluginName" ln -sfn "${JENV_INSTALL_DIR}/available-plugins/$pluginName" "${JENV_ROOT}/plugins/$pluginName"
fi fi

4
libexec/jenv-refresh-versions

@ -11,9 +11,9 @@ set -e
for path in "${JENV_ROOT}/versions/"*; do for path in "${JENV_ROOT}/versions/"*; do
if [ -d "$path" ]; then if [ -d "$path" ]; then
aliasname=$(basename $path) aliasname=$(basename "$path")
if test "${JENV_ROOT}/$aliasname.time" -ot "$path/bin/java"; then if test "${JENV_ROOT}/$aliasname.time" -ot "$path/bin/java"; then
realpath=$(resolve_link $path) realpath="$(resolve_link "$path")"
jenv remove $aliasname >> /dev/null jenv remove $aliasname >> /dev/null
newalias=$(jenv add $realpath) newalias=$(jenv add $realpath)
newalias=${newalias%added} newalias=${newalias%added}

6
libexec/jenv-versions

@ -25,7 +25,7 @@ fi
resolvepath() { resolvepath() {
local cwd="$(pwd)" local cwd="$(pwd)"
cd $1 cd "$1"
echo "$(pwd -P)" echo "$(pwd -P)"
cd "$cwd" cd "$cwd"
} }
@ -37,7 +37,7 @@ print_version() {
if [ "$1" == "$current_version" ]; then if [ "$1" == "$current_version" ]; then
echo "${hit_prefix}$(jenv-version 2>/dev/null)" echo "${hit_prefix}$(jenv-version 2>/dev/null)"
if $verbose ; then if $verbose ; then
local realPath="$(resolvepath $2)" local realPath="$(resolvepath "$2")"
echo " $2" echo " $2"
echo " --> $realPath" echo " --> $realPath"
echo "" echo ""
@ -45,7 +45,7 @@ print_version() {
else else
echo "${miss_prefix}$1" echo "${miss_prefix}$1"
if $verbose ; then if $verbose ; then
local realPath="$(resolvepath $2)" local realPath="$(resolvepath "$2")"
echo " $2" echo " $2"
echo " --> $realPath" echo " --> $realPath"

Loading…
Cancel
Save