Polish "Fix shellcheck warnings in CLI's bash script"

Closes gh-11458
pull/14661/head
Andy Wilkinson 6 years ago
parent 69b844cb13
commit fcc73c6d88

@ -29,21 +29,21 @@ if [ -z "${JAVA_HOME}" ]; then
JAVA_HOME=$(/usr/libexec/java_home)
export JAVA_HOME
fi
if [[ -z "${JAVA_HOME}" && -d "/Library/Java/Home" ]]; then
if [[ -z "${JAVA_HOME}" && -d "/Library/Java/Home" ]]; then
export JAVA_HOME="/Library/Java/Home"
fi
if [[ -z "${JAVA_HOME}" && -d "/System/Library/Frameworks/JavaVM.framework/Home" ]]; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
fi
else
javaExecutable="$(which javac)"
javaExecutable="$(command -v javac)"
if [[ -z "$javaExecutable" || "$(expr "${javaExecutable}" : '\([^ ]*\)')" = "no" ]]; then
echo "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
exit 1
fi
# readlink(1) is not available as standard on Solaris 10.
readLink=(which readlink)
[ $(expr "$readLink" : '\([^ ]*\)') = "no" ] && {
readLink="$(command -v readlink)"
[ "$(expr "${readLink}" : '\([^ ]*\)')" = "no" ] && {
echo "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
exit 1
}
@ -58,39 +58,39 @@ fi
# Sanity check that we have java
if [ ! -f "${JAVA_HOME}/bin/java" ]; then
cat <<-JAVA_HOME_NOT_SET_TXT
======================================================================================================
Please ensure that your JAVA_HOME points to a valid Java SDK.
You are currently pointing to:
${JAVA_HOME}
This does not seem to be valid. Please rectify and restart.
======================================================================================================
JAVA_HOME_NOT_SET_TXT
exit 1
fi
# Attempt to find SPRING_HOME if not already set
if [ -z "${SPRING_HOME}" ]; then
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=$(ls -ld "$PRG")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=$(dirname "$PRG")"/$link"
fi
done
SAVED="$(pwd)"
cd "$(dirname "${PRG}")/../" >&-
SPRING_HOME="$(pwd -P)"
export SPRING_HOME
cd "$SAVED" >&-
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=$(ls -ld "$PRG")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=$(dirname "$PRG")"/$link"
fi
done
SAVED="$(pwd)"
cd "$(dirname "${PRG}")/../" >&- || exit 1
SPRING_HOME="$(pwd -P)"
export SPRING_HOME
cd "$SAVED" >&- || exit 1
fi
if [ ! -d "${SPRING_HOME}" ]; then
@ -103,7 +103,7 @@ CLASSPATH=.:${SPRING_HOME}/bin
if [ -d "${SPRING_HOME}/ext" ]; then
CLASSPATH=$CLASSPATH:${SPRING_HOME}/ext
fi
for f in ${SPRING_HOME}/lib/*; do
for f in "${SPRING_HOME}"/lib/*; do
CLASSPATH=$CLASSPATH:$f
done
@ -112,4 +112,5 @@ if $cygwin; then
CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
fi
"${JAVA_HOME}/bin/java" ${JAVA_OPTS} -cp "$CLASSPATH" org.springframework.boot.loader.JarLauncher "$@"
IFS=" " read -r -a javaOpts <<< "$JAVA_OPTS"
"${JAVA_HOME}/bin/java" "${javaOpts[@]}" -cp "$CLASSPATH" org.springframework.boot.loader.JarLauncher "$@"
Loading…
Cancel
Save