From 8527c84ec3a9a52ed51f97131b84434cf3a75bb0 Mon Sep 17 00:00:00 2001 From: gouvinb Date: Mon, 27 Jan 2025 23:28:48 +0100 Subject: [PATCH] Quote all references to `JENV_ROOT` variables (and variables that use it) to avoid word splitting. This avoids errors where `JENV_ROOT` contains spaces (e.g. `$HOME/Library/Application Support/jenv`). --- libexec/jenv | 2 +- libexec/jenv---version | 2 +- libexec/jenv-add | 2 +- libexec/jenv-disable-plugin | 2 +- libexec/jenv-doctor | 2 +- libexec/jenv-refresh-plugins | 2 +- libexec/jenv-remove | 4 ++-- libexec/jenv-root | 2 +- libexec/jenv-sh-enable-plugin | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libexec/jenv b/libexec/jenv index 589d5fb..34a1a04 100755 --- a/libexec/jenv +++ b/libexec/jenv @@ -72,7 +72,7 @@ bin_path="$(abs_dirname "$0")" if ! samedir "${JENV_ROOT}" "$bin_path/../" ; then JENV_INSTALL_DIR=$(resolvepath "$bin_path/../") else - JENV_INSTALL_DIR=$JENV_ROOT + JENV_INSTALL_DIR="$JENV_ROOT" fi export JENV_INSTALL_DIR diff --git a/libexec/jenv---version b/libexec/jenv---version index 096fcf3..da5a951 100755 --- a/libexec/jenv---version +++ b/libexec/jenv---version @@ -14,7 +14,7 @@ set -e version="0.5.7" -if [ -d $JENV_ROOT ]; then +if [ -d "$JENV_ROOT" ]; then cd "$JENV_ROOT" git_revision="$(git describe --tags HEAD 2>/dev/null || true)" git_revision="${git_revision#v}" diff --git a/libexec/jenv-add b/libexec/jenv-add index 56a16ad..a82a769 100755 --- a/libexec/jenv-add +++ b/libexec/jenv-add @@ -63,7 +63,7 @@ function add_alias(){ cd - 2>&1 > /dev/null mkdir -p "${JENV_ROOT}/versions" ln -s "${JENV_JAVAPATH}" "${JENV_ROOT}/versions/$1" - touch ${JENV_ROOT}/$1.time + touch "${JENV_ROOT}/$1.time" cinfo "$1 added" version_added=true diff --git a/libexec/jenv-disable-plugin b/libexec/jenv-disable-plugin index 2bf8d1b..8e6f85d 100755 --- a/libexec/jenv-disable-plugin +++ b/libexec/jenv-disable-plugin @@ -16,7 +16,7 @@ fi plugin="$1" -if [ -h ${JENV_ROOT}/plugins/$plugin ]; then +if [ -h "${JENV_ROOT}/plugins/$plugin" ]; then if [ -f "${JENV_ROOT}/plugins/$plugin/etc/jenv.d/unload/after.bash" ]; then source "${JENV_ROOT}/plugins/$plugin/etc/jenv.d/unload/after.bash" fi diff --git a/libexec/jenv-doctor b/libexec/jenv-doctor index 4941837..61669ec 100755 --- a/libexec/jenv-doctor +++ b/libexec/jenv-doctor @@ -99,7 +99,7 @@ for plugin in "$JENV_ROOT"/plugins/*; do pluginName=$(basename "$plugin") if ! targetLink=$(resolve_link "$plugin"); then cwarn "Plugin $pluginName is not linked to a jenv installation" - elif [[ ! $targetLink == $JENV_INSTALL_DIR* ]]; then + elif [[ ! $targetLink == "$JENV_INSTALL_DIR"* ]]; then cwarn "Plugin $pluginName is linked to older jenv installation" cfix "Please execute : jenv disable-plugin $pluginName && jenv enable-plugin $pluginName" fi diff --git a/libexec/jenv-refresh-plugins b/libexec/jenv-refresh-plugins index c895a86..bd4e518 100755 --- a/libexec/jenv-refresh-plugins +++ b/libexec/jenv-refresh-plugins @@ -11,7 +11,7 @@ set -e FORCE_REFRESH=0 if [ ! -f "${JENV_ROOT}/jenv.version" ]; then - echo "NONE" > ${JENV_ROOT}/jenv.version + echo "NONE" > "${JENV_ROOT}/jenv.version" fi if [ "$1" = "--complete" ]; then diff --git a/libexec/jenv-remove b/libexec/jenv-remove index 43b568e..317e566 100755 --- a/libexec/jenv-remove +++ b/libexec/jenv-remove @@ -16,8 +16,8 @@ do if [ -L "$JENV_ROOT/versions/$JENV_VERSION" ]; then - rm -f $JENV_ROOT/versions/$JENV_VERSION - rm -f ${JENV_ROOT}/$JENV_VERSION.time + rm -f "$JENV_ROOT/versions/$JENV_VERSION" + rm -f "${JENV_ROOT}/$JENV_VERSION.time" echo "JDK $JENV_VERSION removed" else diff --git a/libexec/jenv-root b/libexec/jenv-root index c51f624..c9b498d 100755 --- a/libexec/jenv-root +++ b/libexec/jenv-root @@ -1,3 +1,3 @@ #!/usr/bin/env bash # Summary: Display the root directory where versions and shims are kept -echo $JENV_ROOT +echo "$JENV_ROOT" diff --git a/libexec/jenv-sh-enable-plugin b/libexec/jenv-sh-enable-plugin index 7631ffe..8cbf9f0 100755 --- a/libexec/jenv-sh-enable-plugin +++ b/libexec/jenv-sh-enable-plugin @@ -18,7 +18,7 @@ fi plugin="$1" -if [ -h ${JENV_ROOT}/plugins/$plugin ]; then +if [ -h "${JENV_ROOT}/plugins/$plugin" ]; then echo "echo $plugin plugin already enabled" else if [ ! -d "${JENV_INSTALL_DIR}/available-plugins/$plugin" ]; then