[CORD-3083]
Verify jobs on automation-tools repo
Add shellcheck linting

Change-Id: Iddcf439a0f2f8046309c999a0a3b3f7774925849
diff --git a/jjb/shell/licensecheck.sh b/jjb/shell/licensecheck.sh
index 42b6b87..e40802a 100755
--- a/jjb/shell/licensecheck.sh
+++ b/jjb/shell/licensecheck.sh
@@ -1,14 +1,21 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
 
 # licensecheck.sh
 # checks for copyright/license headers on files
 # excludes filename extensions where this check isn't pertinent
 
-# this could be rewritten with better form. Currently is a cut/paste from the
-# Jenkins job with minimal changes (BSD/OS X xargs params compat, sort of
-# excluded file extensions).
+set +e -u -o pipefail
+fail_licensecheck=0
 
-find . -name ".git" -prune -o -type f \
+while IFS= read -r -d '' f
+do
+  grep -q "Copyright\|Apache License" "${f}"
+  rc=$?
+  if [[ $rc != 0 ]]; then
+    echo "ERROR: $f does not contain License Header"
+    fail_licensecheck=1
+  fi
+done < <(find . -name ".git" -prune -o -type f \
   -name "*.*" \
   ! -name "*.PNG" \
   ! -name "*.asc" \
@@ -82,6 +89,7 @@
   ! -path "*conf*" \
   ! -path "*git*" \
   ! -path "*swagger*" \
-  -print0 |   \
-  xargs -0 -n1 sh -c 'if ! grep -q "Copyright\|Apache License" $0; then echo "ERROR: $0 does not contain Copyright header"; exit 1; fi;'
+  -print0 )
+
+exit ${fail_licensecheck}