Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 00cdf26

Browse files
committed
make Shellcheck happier // refs #56
- JVMMainClass: https://github.com/koalaman/shellcheck/wiki/SC2086 - `cd` commands with different exit code: https://github.com/koalaman/shellcheck/wiki/SC2164 - `read`: https://github.com/koalaman/shellcheck/wiki/SC2162 - replace `sed` by parameter expansion: https://github.com/koalaman/shellcheck/wiki/SC2001 - backtick commands replaced by $(..): https://github.com/koalaman/shellcheck/wiki/SC2006
1 parent f298a60 commit 00cdf26

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

src/universalJavaApplicationStub

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ function stub_logger() {
6565

6666
PRG=$0
6767
while [ -h "$PRG" ]; do
68-
ls=`ls -ld "$PRG"`
69-
link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
68+
ls=$(ls -ld "$PRG")
69+
link=$(expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null)
7070
if expr "$link" : '^/' 2> /dev/null >/dev/null; then
7171
PRG="$link"
7272
else
73-
PRG="`dirname "$PRG"`/$link"
73+
PRG="$(dirname "$PRG")/$link"
7474
fi
7575
done
76-
PROGDIR=`dirname "$PRG"`
76+
PROGDIR=$(dirname "$PRG")
7777
stub_logger "[StubDir] $PROGDIR"
7878

7979

@@ -82,12 +82,12 @@ stub_logger "[StubDir] $PROGDIR"
8282
############################################
8383

8484
# the absolute path of the app package
85-
cd "$PROGDIR"/../../
86-
AppPackageFolder=`pwd`
85+
cd "$PROGDIR"/../../ || exit 11
86+
AppPackageFolder=$(pwd)
8787

8888
# the base path of the app package
89-
cd ..
90-
AppPackageRoot=`pwd`
89+
cd .. || exit 12
90+
AppPackageRoot=$(pwd)
9191

9292
# set Apple's Java folder
9393
AppleJavaFolder="${AppPackageFolder}"/Contents/Resources/Java
@@ -185,7 +185,7 @@ if [ $exitcode -eq 0 ]; then
185185

186186

187187
# read the MainClass name
188-
JVMMainClass=$(plist_get_java ':MainClass')
188+
JVMMainClass="$(plist_get_java ':MainClass')"
189189

190190
# read the SplashFile name
191191
JVMSplashFile=$(plist_get_java ':SplashFile')
@@ -229,8 +229,8 @@ if [ $exitcode -eq 0 ]; then
229229
JVMVersion=$(plist_get_java ':JVMVersion' | xargs)
230230
if [[ ${JVMVersion} == *";"* ]]; then
231231
minMaxArray=(${JVMVersion//;/ })
232-
JVMVersion=$(echo ${minMaxArray[0]} | sed 's/+//')
233-
JVMMaxVersion=$(echo ${minMaxArray[1]} | sed 's/+//')
232+
JVMVersion=${minMaxArray[0]//+}
233+
JVMMaxVersion=${minMaxArray[1]//+}
234234
fi
235235
stub_logger "[JavaRequirement] JVM minimum version: ${JVMVersion}"
236236
stub_logger "[JavaRequirement] JVM maximum version: ${JVMMaxVersion}"
@@ -248,7 +248,7 @@ else
248248
APP_ROOT="${AppPackageFolder}"
249249

250250
# read the MainClass name
251-
JVMMainClass=$(plist_get ':JVMMainClassName')
251+
JVMMainClass="$(plist_get ':JVMMainClassName')"
252252

253253
# read the SplashFile name
254254
JVMSplashFile=$(plist_get ':JVMSplashFile')
@@ -516,7 +516,7 @@ if [ -z "${JAVACMD}" ] || [ ! -x "${JAVACMD}" ] ; then
516516
# find installed JavaVirtualMachines (JDK + JRE)
517517
allJVMs=()
518518
# read JDK's from '/usr/libexec/java_home -V' command
519-
while read line; do
519+
while read -r line; do
520520
version=$(echo $line | awk -F $',' '{print $1;}')
521521
path=$(echo $line | awk -F $'" ' '{print $2;}')
522522
path+="/bin/java"
@@ -707,7 +707,7 @@ fi
707707
# MainClass check
708708
############################################
709709

710-
if [ -z ${JVMMainClass} ]; then
710+
if [ -z "${JVMMainClass}" ]; then
711711
# log exit cause
712712
stub_logger "[EXIT 2] ${MSG_MISSING_MAINCLASS}"
713713
# display error message with AppleScript
@@ -732,7 +732,7 @@ else
732732
fi
733733

734734
# change to Working Directory based upon Apple/Oracle Plist info
735-
cd "${WorkingDirectory}"
735+
cd "${WorkingDirectory}" || exit 13
736736
stub_logger "[WorkingDirectory] ${WorkingDirectory}"
737737

738738
# execute Java and set
@@ -753,6 +753,6 @@ exec "${JAVACMD}" \
753753
-Xdock:name="${CFBundleName}" \
754754
${JVMOptions:+$JVMOptions }\
755755
${JVMDefaultOptions:+$JVMDefaultOptions }\
756-
${JVMMainClass}\
756+
"${JVMMainClass}"\
757757
${MainArgsArr:+ "${MainArgsArr[@]}"}\
758758
${ArgsPassthru:+ "${ArgsPassthru[@]}"}

0 commit comments

Comments
 (0)