Fix ShellCheck for patch-odl-release 95/4095/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Sat, 4 Mar 2017 18:04:04 +0000 (13:04 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Sat, 4 Mar 2017 18:04:04 +0000 (13:04 -0500)
Change-Id: Ief138884ec71f2d5713dae7c2f71b7247052be08
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
shell/patch-odl-release

index 369ec59..b6779ae 100755 (executable)
@@ -31,23 +31,23 @@ fi
 
 PATCH_DIR=$1
 RELEASE_TAG=$2
-STABLE_BRANCH="stable/$( cut -d '-' -f1 <<< ${RELEASE_TAG,,})"
+STABLE_BRANCH="stable/$( cut -d '-' -f1 <<< "${RELEASE_TAG,,}")"
 
-project=${PWD##*/}
+project="${PWD##*/}"
 scriptdir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
 
 # Validate that we're patching at the same commit level as when autorelease
 # built the release. Basically ensuring that no new patches snuck into the
 # project during code freeze.
-EXPECTED_HASH=`grep "^${project} " $PATCH_DIR/taglist.log | awk '{ print $2 }'`
+EXPECTED_HASH=$(grep "^${project} " "$PATCH_DIR/taglist.log" | awk '{ print $2 }')
 if [ "$EXPECTED_HASH" == "" ]; then
-    parent_dir="$(dirname `pwd`)"
+    parent_dir="$(dirname "$(pwd)")"
     project="${parent_dir##*/}/$project"
-    EXPECTED_HASH=`grep "^${project} " $PATCH_DIR/taglist.log | awk '{ print $2 }'`
+    EXPECTED_HASH=$(grep "^${project} " "$PATCH_DIR/taglist.log" | awk '{ print $2 }')
 fi
 
 git checkout "$EXPECTED_HASH"
-CURRENT_HASH=`git rev-parse HEAD`
+CURRENT_HASH=$(git rev-parse HEAD)
 
 echo "Current Hash: $CURRENT_HASH"
 echo "Expected Hash: $EXPECTED_HASH"
@@ -61,16 +61,16 @@ fi
 #######################
 # Start apply patches #
 #######################
-git fetch ${PATCH_DIR}/${project/\//-}.bundle
+git fetch "${PATCH_DIR}/${project/\//-}.bundle"
 git merge FETCH_HEAD
-git tag -asm "OpenDaylight $RELEASE_TAG release" release/${RELEASE_TAG,,}
-find . -name pom.xml | xargs grep SNAPSHOT
+git tag -asm "OpenDaylight $RELEASE_TAG release" "release/${RELEASE_TAG,,}"
+find . -name pom.xml -print0 | xargs -0 grep SNAPSHOT
 
-git checkout ${STABLE_BRANCH}
+git checkout "${STABLE_BRANCH}"
 # Release and then Bump so that the version.sh script creates the right patches
-$scriptdir/version.sh release $RELEASE_TAG
-$scriptdir/version.sh bump $RELEASE_TAG
+"$scriptdir/version.sh" release "$RELEASE_TAG"
+"$scriptdir/version.sh" bump "$RELEASE_TAG"
 git commit -asm "Bumping versions by 0.0.1 for next dev cycle"
-find . -name pom.xml | xargs grep $RELEASE_TAG
+find . -name pom.xml -print0 | xargs -0 grep "$RELEASE_TAG"
 
 echo "Tagging and version bumping complete"