diff --git a/cluster/gce/gci/flexvolume_node_setup.sh b/cluster/gce/gci/flexvolume_node_setup.sh index cad4b48e80f..ce4d995e95d 100755 --- a/cluster/gce/gci/flexvolume_node_setup.sh +++ b/cluster/gce/gci/flexvolume_node_setup.sh @@ -81,10 +81,10 @@ flex_clean() { umount_silent ${MOUNTER_PATH} rm -rf ${MOUNTER_PATH} - if [ -n ${IMAGE_URL:-} ]; then + if [[ -n ${IMAGE_URL:-} ]]; then docker rmi -f ${IMAGE_URL} &> /dev/null || /bin/true fi - if [ -n ${MOUNTER_DEFAULT_NAME:-} ]; then + if [[ -n ${MOUNTER_DEFAULT_NAME:-} ]]; then docker rm -f ${MOUNTER_DEFAULT_NAME} &> /dev/null || /bin/true fi } diff --git a/cluster/gce/list-resources.sh b/cluster/gce/list-resources.sh index a63be2c24f9..a95f9c50f76 100755 --- a/cluster/gce/list-resources.sh +++ b/cluster/gce/list-resources.sh @@ -57,7 +57,7 @@ function gcloud-compute-list() { fi echo -e "Attempt ${attempt} failed to list ${resource}. Retrying." >&2 attempt=$(($attempt+1)) - if [[ ${attempt} > 5 ]]; then + if [[ ${attempt} -gt 5 ]]; then echo -e "List ${resource} failed!" >&2 exit 2 fi diff --git a/cluster/gce/upgrade-aliases.sh b/cluster/gce/upgrade-aliases.sh index 29dbf0232ed..410cd639d88 100755 --- a/cluster/gce/upgrade-aliases.sh +++ b/cluster/gce/upgrade-aliases.sh @@ -53,7 +53,7 @@ function detect-k8s-subnetwork() { local subnetwork_url=$(gcloud compute instances describe \ ${KUBE_MASTER} --project=${PROJECT} --zone=${ZONE} \ --format='value(networkInterfaces[0].subnetwork)') - if [ -n ${subnetwork_url} ]; then + if [[ -n ${subnetwork_url} ]]; then IP_ALIAS_SUBNETWORK=$(echo ${subnetwork_url##*/}) fi } diff --git a/hack/update-godep-licenses.sh b/hack/update-godep-licenses.sh index 34e064672e9..bd9679968b4 100755 --- a/hack/update-godep-licenses.sh +++ b/hack/update-godep-licenses.sh @@ -74,10 +74,10 @@ process_content () { # Start search at package root case ${package} in github.com/*|golang.org/*|bitbucket.org/*) - package_root=$(echo ${package} |awk -F/ '{ print $1"/"$2"/"$3 }') + package_root=$(echo "${package}" |awk -F/ '{ print $1"/"$2"/"$3 }') ;; go4.org/*) - package_root=$(echo ${package} |awk -F/ '{ print $1 }') + package_root=$(echo "${package}" |awk -F/ '{ print $1 }') ;; gopkg.in/*) # Root of gopkg.in package always ends with '.v(number)' and my contain @@ -85,10 +85,10 @@ process_content () { # - gopkg.in/yaml.v2 # - gopkg.in/inf.v0 # - gopkg.in/square/go-jose.v2 - package_root=$(echo ${package} |grep -oh '.*\.v[0-9]') + package_root=$(echo "${package}" |grep -oh '.*\.v[0-9]') ;; *) - package_root=$(echo ${package} |awk -F/ '{ print $1"/"$2 }') + package_root=$(echo "${package}" |awk -F/ '{ print $1"/"$2 }') ;; esac @@ -98,7 +98,7 @@ process_content () { [[ -d ${DEPS_DIR}/${dir_root} ]] || continue # One (set) of these is fine - find ${DEPS_DIR}/${dir_root} \ + find "${DEPS_DIR}/${dir_root}" \ -xdev -follow -maxdepth ${find_maxdepth} \ -type f "${find_names[@]}" done | sort -u)) @@ -107,9 +107,14 @@ process_content () { local f index="${package}-${type}" if [[ -z "${CONTENT[${index}]-}" ]]; then - for f in ${local_files[@]-}; do + for f in "${local_files[@]-}"; do + if [[ -z "$f" ]]; then + # Set the default value and then check it to prevent + # accessing potentially empty array + continue + fi # Find some copyright info in any file and break - if egrep -i -wq "${ensure_pattern}" "${f}"; then + if grep -E -i -wq "${ensure_pattern}" "${f}"; then CONTENT[${index}]="${f}" break fi @@ -151,19 +156,17 @@ declare -Ag CONTENT echo "================================================================================" echo "= Kubernetes licensed under: =" echo -cat ${LICENSE_ROOT}/LICENSE +cat "${LICENSE_ROOT}/LICENSE" echo -echo "= LICENSE $(cat ${LICENSE_ROOT}/LICENSE | md5sum | awk '{print $1}')" +echo "= LICENSE $(cat "${LICENSE_ROOT}/LICENSE" | md5sum | awk '{print $1}')" echo "================================================================================" ) > ${TMP_LICENSE_FILE} # Loop through every package in Godeps.json -for PACKAGE in $(cat Godeps/Godeps.json | \ - jq -r ".Deps[].ImportPath" | \ - sort -f); do - process_content ${PACKAGE} LICENSE - process_content ${PACKAGE} COPYRIGHT - process_content ${PACKAGE} COPYING +for PACKAGE in $(jq -r ".Deps[].ImportPath" < Godeps/Godeps.json | sort -f); do + process_content "${PACKAGE}" LICENSE + process_content "${PACKAGE}" COPYRIGHT + process_content "${PACKAGE}" COPYING # display content echo @@ -195,7 +198,7 @@ __EOF__ cat "${file}" echo - echo "= ${file} $(cat ${file} | md5sum | awk '{print $1}')" + echo "= ${file} $(cat "${file}" | md5sum | awk '{print $1}')" echo "================================================================================" echo done >> ${TMP_LICENSE_FILE} diff --git a/hack/verify-cli-conventions.sh b/hack/verify-cli-conventions.sh index d768eb0a560..935d5dc0d71 100755 --- a/hack/verify-cli-conventions.sh +++ b/hack/verify-cli-conventions.sh @@ -30,7 +30,7 @@ make -C "${KUBE_ROOT}" WHAT="${BINS[*]}" clicheck=$(kube::util::find-binary "clicheck") -if ! output=`$clicheck 2>&1` +if ! output=$($clicheck 2>&1) then echo "$output" echo diff --git a/hack/verify-godeps.sh b/hack/verify-godeps.sh index b03826e7449..057da6b1536 100755 --- a/hack/verify-godeps.sh +++ b/hack/verify-godeps.sh @@ -65,7 +65,7 @@ _kubetmp="${_kubetmp}/kubernetes" # Do all our work in the new GOPATH export GOPATH="${_tmpdir}" -pushd "${_kubetmp}" 2>&1 > /dev/null +pushd "${_kubetmp}" > /dev/null 2>&1 # Restore the Godeps into our temp directory hack/godep-restore.sh @@ -78,11 +78,11 @@ pushd "${_kubetmp}" 2>&1 > /dev/null # Recreate the Godeps using the nice clean set we just downloaded hack/godep-save.sh -popd 2>&1 > /dev/null +popd > /dev/null 2>&1 ret=0 -pushd "${KUBE_ROOT}" 2>&1 > /dev/null +pushd "${KUBE_ROOT}" > /dev/null 2>&1 # Test for diffs if ! _out="$(diff -Naupr --ignore-matching-lines='^\s*\"GoVersion\":' --ignore-matching-line='^\s*\"GodepVersion\":' --ignore-matching-lines='^\s*\"Comment\":' Godeps/Godeps.json ${_kubetmp}/Godeps/Godeps.json)"; then echo "Your Godeps.json is different:" >&2 @@ -117,9 +117,9 @@ pushd "${KUBE_ROOT}" 2>&1 > /dev/null fi ret=1 fi -popd 2>&1 > /dev/null +popd > /dev/null 2>&1 -if [[ ${ret} > 0 ]]; then +if [[ ${ret} -gt 0 ]]; then exit ${ret} fi diff --git a/pkg/util/verify-util-pkg.sh b/pkg/util/verify-util-pkg.sh index 755924a099a..2b8d628ebc0 100755 --- a/pkg/util/verify-util-pkg.sh +++ b/pkg/util/verify-util-pkg.sh @@ -41,7 +41,7 @@ pushd "${BASH_DIR}" > /dev/null done popd > /dev/null -if [[ ${ret} > 0 ]]; then +if [[ ${ret} -gt 0 ]]; then exit ${ret} fi