Sorcerer's IsleCode Lucee on Jetty / diff

f141a0e Cleanup assorted Bash mistakes and pitfalls.

 build/build.sh | 46 ++++++++++----------
 1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/build/build.sh b/build/build.sh
index 6491650..0fc6883 100644
--- a/build/build.sh
+++ b/build/build.sh
@@ -2,26 +2,26 @@
 
 echo -e "\n\e[1;97mBuilding Lucee on Jetty!\e[0m\n"
 
-JettyFile=`echo $* | perl -ne 'print $_ =~ /--jetty=(\S+)/'`
-LuceeFile=`echo $* | perl -ne 'print $_ =~ /--lucee=(\S+)/'`
+JettyFile=$(echo "$@" | perl -ne 'print $_ =~ /--jetty=(\S+)/')
+LuceeFile=$(echo "$@" | perl -ne 'print $_ =~ /--lucee=(\S+)/')
 Errors=0
 
-if [ -z $JettyFile ]; then
+if [ -z "$JettyFile" ]; then
 	echo "Specify --jetty=/path/to/jetty-distribution.tgz"
 	Errors=1
 fi
 
-if [ -z $LuceeFile ]; then
+if [ -z "$LuceeFile" ]; then
 	echo "Specify --lucee=/path/to/lucee.jar"
 	Errors=1
 fi
 
-if [ ! -f $JettyFile ]; then
+if [ ! -f "$JettyFile" ]; then
 	echo "Invalid Jetty file [$JettyFile]"
 	Errors=1
 fi
 
-if [ ! -f $LuceeFile ]; then
+if [ ! -f "$LuceeFile" ]; then
 	echo "Invalid Lucee file [$LuceeFile]"
 	Errors=1
 fi
@@ -32,24 +32,24 @@ if [ $Errors -ne 0 ]; then
 fi
 
 
-cd `dirname $0`
-echo "In build directory [`pwd`]"
+cd "$(dirname "$0")" || { echo "ERROR: cd failed" ; exit ; }
+echo "In build directory [$PWD]"
 
-WorkingDir=luje-`date '+%s'`
-mkdir $WorkingDir
+WorkingDir=luje-$(date '+%s')
+mkdir "$WorkingDir"
 
-cd $WorkingDir
-echo "In working directory [`pwd`]"
+cd "$WorkingDir" || { echo "ERROR: cd failed" ; exit ; }
+echo "In working directory [$PWD]"
 
 echo "1/5 Copying template files"
 cp -r ../../src/* ./
 
 echo "2/5 Extracing $JettyFile"
-if [ ${JettyFile##*.} = "zip" ]
+if [ "${JettyFile##*.}" = "zip" ]
 then
-	unzip -q $JettyFile
+	unzip -q "$JettyFile"
 else
-	tar -xzf $JettyFile
+	tar -xzf "$JettyFile"
 fi
 shopt -s nullglob
 mv jetty-{home,distribution}-* jetty-home
@@ -60,22 +60,22 @@ if [ ! -d jetty-home ]; then
 fi
 
 echo "3/5 Extracing $LuceeFile"
-cp $LuceeFile lucee-base/modules/lucee/lib/
+cp "$LuceeFile" lucee-base/modules/lucee/lib/
 rm lucee-base/modules/lucee/lib/lucee_jar_goes_here
 
-JettyVersion=`echo $JettyFile | perl -ne 'print $_ =~ /jetty-(?:distribution|home)-([\d.]*)(?:(\.M\d)|\.v\d+)\.(?:zip|tgz|tar\.gz)$/'`
-LuceeVersion=`echo $LuceeFile | perl -ne 'print $_ =~ /lucee-(?:light-)?([\d.]*).jar$/'`
+JettyVersion=$(echo "$JettyFile" | perl -ne 'print $_ =~ /jetty-(?:distribution|home)-([\d.]*)(?:(\.M\d)|\.v\d+)\.(?:zip|tgz|tar\.gz)$/')
+LuceeVersion=$(echo "$LuceeFile" | perl -ne 'print $_ =~ /lucee-(?:light-)?([\d.]*).jar$/')
 echo "4/5 Setting versions [$JettyVersion] and [$LuceeVersion]"
 [ -z "$JettyVersion" ] && echo "WARNING: failed to read version from filename [$JettyFile]"
 [ -z "$LuceeVersion" ] && echo "WARNING: failed to read version from filename [$LuceeFile]"
-sed s/{JETTY_VERSION}/$JettyVersion/g < README.TXT > README.TMP
-sed s/{LUCEE_VERSION}/$LuceeVersion/g < README.TMP > README.TXT
+sed "s/{JETTY_VERSION}/$JettyVersion/g" < README.TXT > README.TMP
+sed "s/{LUCEE_VERSION}/$LuceeVersion/g" < README.TMP > README.TXT
 rm README.TMP
 
 echo "5/5 Creating dist/$WorkingDir.tgz"
 mkdir -p ../../dist
-tar -czf ../../dist/$WorkingDir.tgz *
-cd ..
-rm -r $WorkingDir
+tar -czf "../../dist/$WorkingDir.tgz" -- *
+cd .. || { echo "ERROR: cd failed" ; exit ; }
+rm -r "$WorkingDir"
 
 echo -e "\n\e[1;97mBuild Complete!\e[0m\n"