From a87e7cdccc2903e54a30c0c71e39f0ff3c71f2a7 Mon Sep 17 00:00:00 2001 From: James Munnelly Date: Mon, 10 Sep 2018 20:42:48 +0100 Subject: [PATCH] Use mktemp in verify-errexit and verify-links Signed-off-by: James Munnelly --- hack/verify-errexit.sh | 9 ++++++--- hack/verify-links.sh | 5 ++--- hack/verify_boilerplate.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hack/verify-errexit.sh b/hack/verify-errexit.sh index cd3a175c1..ff96e7d5c 100755 --- a/hack/verify-errexit.sh +++ b/hack/verify-errexit.sh @@ -31,14 +31,17 @@ REPO_ROOT=$(dirname "${BASH_SOURCE}")/.. if [ "$*" != "" ]; then args="$*" else - args=$(ls "$REPO_ROOT" | grep -v vendor | grep -v glide) + args=$(ls "$REPO_ROOT" | grep -v vendor | grep -v glide | grep -v 'bazel-' ) fi # Gather the list of files that appear to be shell scripts. # Meaning they have some form of "#!...sh" as a line in them. -shFiles=$(grep -rl '^#!.*sh$' $args) +shFiles=$(grep -Rrl '^#!.*sh$' $args) + +tmp=$(mktemp) +# Delete the temporary file as it should only exist if errors have occurred. +rm $tmp -tmp=/tmp/out$RANDOM for file in ${shFiles}; do grep "set -o errexit" $file > /dev/null 2>&1 && continue grep "set -[a-z]*e" $file > /dev/null 2>&1 && continue diff --git a/hack/verify-links.sh b/hack/verify-links.sh index 54d2f221f..ceea80b12 100755 --- a/hack/verify-links.sh +++ b/hack/verify-links.sh @@ -38,9 +38,8 @@ fi mdFiles=$(find "${args}" -name "*.md" | grep -v vendor | grep -v glide) -tmp=/tmp/out${RANDOM} +tmp=$(mktemp) -rm -f /tmp/$tmp* for file in ${mdFiles}; do # echo scanning $file dir=$(dirname $file) @@ -74,7 +73,7 @@ for file in ${mdFiles}; do # An external href (ie. starts with http) if [ "${ref:0:4}" == "http" ]; then - if ! curl --connect-timeout 10 -o /dev/null ${ref} > /dev/null 2>&1 ; then + if ! wget --timeout 10 -o /dev/null ${ref} > /dev/null 2>&1 ; then echo $file: Can\'t load: url ${ref} | tee -a ${tmp}3 fi continue diff --git a/hack/verify_boilerplate.py b/hack/verify_boilerplate.py index 898f2ea83..db83408e2 100755 --- a/hack/verify_boilerplate.py +++ b/hack/verify_boilerplate.py @@ -115,7 +115,7 @@ def file_extension(filename): SKIPPED_DIRS = [ 'Godeps', 'third_party', '_gopath', '_output', - '.git', 'vendor', '__init__.py', 'node_modules' + '.git', 'vendor', '__init__.py', 'node_modules', ] # even when generated by bazel we will complain about some generated files