From e05f85a6116a8c8056a9d8224de3a10543a3a3ac Mon Sep 17 00:00:00 2001 From: aaa <1693291525@qq.com> Date: Fri, 19 Apr 2019 14:59:50 -0400 Subject: [PATCH] Fix shellcheck failures on verify-readonly-packages.sh --- hack/.shellcheck_failures | 1 - hack/verify-readonly-packages.sh | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hack/.shellcheck_failures b/hack/.shellcheck_failures index 3eac39a72b3..55ef10e6d69 100644 --- a/hack/.shellcheck_failures +++ b/hack/.shellcheck_failures @@ -47,7 +47,6 @@ ./hack/verify-golint.sh ./hack/verify-no-vendor-cycles.sh ./hack/verify-openapi-spec.sh -./hack/verify-readonly-packages.sh ./hack/verify-test-featuregates.sh ./test/cmd/apply.sh ./test/cmd/apps.sh diff --git a/hack/verify-readonly-packages.sh b/hack/verify-readonly-packages.sh index 014984c904e..56d59cc7f01 100755 --- a/hack/verify-readonly-packages.sh +++ b/hack/verify-readonly-packages.sh @@ -22,7 +22,7 @@ set -o errexit set -o nounset set -o pipefail -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. +KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" readonly branch=${1:-${KUBE_VERIFY_GIT_BRANCH:-master}} @@ -44,12 +44,17 @@ find_files() { } IFS=$'\n' -conflicts=($(find_files | sed 's|/.readonly||' | while read dir; do + +conflicts=() +while IFS=$'\n' read -r line; do + conflicts+=( "$line" ) +done < <(find_files | sed 's|/.readonly||' | while read -r dir; do dir=${dir#./} if kube::util::has_changes "${branch}" "^${dir}/[^/]*\$" '/\.readonly$|/BUILD$|/zz_generated|/\.generated\.|\.proto$|\.pb\.go$' >/dev/null; then echo "${dir}" fi -done)) +done) + unset IFS if [ ${#conflicts[@]} -gt 0 ]; then