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

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

@ -36,14 +36,14 @@ if [ -z "${JAVA_HOME}" ]; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
fi fi
else else
javaExecutable="$(which javac)" javaExecutable="$(command -v javac)"
if [[ -z "$javaExecutable" || "$(expr "${javaExecutable}" : '\([^ ]*\)')" = "no" ]]; then if [[ -z "$javaExecutable" || "$(expr "${javaExecutable}" : '\([^ ]*\)')" = "no" ]]; then
echo "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME." echo "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
exit 1 exit 1
fi fi
# readlink(1) is not available as standard on Solaris 10. # readlink(1) is not available as standard on Solaris 10.
readLink=(which readlink) readLink="$(command -v readlink)"
[ $(expr "$readLink" : '\([^ ]*\)') = "no" ] && { [ "$(expr "${readLink}" : '\([^ ]*\)')" = "no" ] && {
echo "JAVA_HOME not set and readlink not available, please set JAVA_HOME." echo "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
exit 1 exit 1
} }
@ -74,23 +74,23 @@ fi
# Attempt to find SPRING_HOME if not already set # Attempt to find SPRING_HOME if not already set
if [ -z "${SPRING_HOME}" ]; then if [ -z "${SPRING_HOME}" ]; then
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" PRG="$0"
# Need this for relative symlinks. # Need this for relative symlinks.
while [ -h "$PRG" ] ; do while [ -h "$PRG" ] ; do
ls=$(ls -ld "$PRG") ls=$(ls -ld "$PRG")
link=$(expr "$ls" : '.*-> \(.*\)$') link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' > /dev/null; then if expr "$link" : '/.*' > /dev/null; then
PRG="$link" PRG="$link"
else else
PRG=$(dirname "$PRG")"/$link" PRG=$(dirname "$PRG")"/$link"
fi fi
done done
SAVED="$(pwd)" SAVED="$(pwd)"
cd "$(dirname "${PRG}")/../" >&- cd "$(dirname "${PRG}")/../" >&- || exit 1
SPRING_HOME="$(pwd -P)" SPRING_HOME="$(pwd -P)"
export SPRING_HOME export SPRING_HOME
cd "$SAVED" >&- cd "$SAVED" >&- || exit 1
fi fi
if [ ! -d "${SPRING_HOME}" ]; then if [ ! -d "${SPRING_HOME}" ]; then
@ -103,7 +103,7 @@ CLASSPATH=.:${SPRING_HOME}/bin
if [ -d "${SPRING_HOME}/ext" ]; then if [ -d "${SPRING_HOME}/ext" ]; then
CLASSPATH=$CLASSPATH:${SPRING_HOME}/ext CLASSPATH=$CLASSPATH:${SPRING_HOME}/ext
fi fi
for f in ${SPRING_HOME}/lib/*; do for f in "${SPRING_HOME}"/lib/*; do
CLASSPATH=$CLASSPATH:$f CLASSPATH=$CLASSPATH:$f
done done
@ -112,4 +112,5 @@ if $cygwin; then
CLASSPATH=$(cygpath --path --mixed "$CLASSPATH") CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
fi 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