Skip to content

Commit 9a5655c

Browse files
committed
fix shellcheck failures in /hack/make-rules/update.sh,verify.sh
1 parent b3a73f7 commit 9a5655c

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

hack/.shellcheck_failures

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
./hack/lib/version.sh
2525
./hack/make-rules/make-help.sh
2626
./hack/make-rules/test.sh
27-
./hack/make-rules/update.sh
28-
./hack/make-rules/verify.sh
2927
./hack/pin-dependency.sh
3028
./hack/test-integration.sh
3129
./hack/update-vendor.sh

hack/make-rules/update.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -o errexit
1919
set -o nounset
2020
set -o pipefail
2121

22-
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
22+
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
2323
source "${KUBE_ROOT}/hack/lib/init.sh"
2424

2525
# If called directly, exit.
@@ -32,10 +32,6 @@ fi
3232

3333
SILENT=${SILENT:-true}
3434
ALL=${FORCE_ALL:-false}
35-
V=""
36-
if [[ "${SILENT}" != "true" ]]; then
37-
V="-v"
38-
fi
3935

4036
trap 'exit 1' SIGINT
4137

@@ -59,10 +55,10 @@ BASH_TARGETS="
5955
update-gofmt"
6056

6157
for t in ${BASH_TARGETS}; do
62-
echo -e "${color_yellow}Running ${t}${color_norm}"
58+
echo -e "${color_yellow:?}Running ${t}${color_norm:?}"
6359
if ${SILENT} ; then
6460
if ! bash "${KUBE_ROOT}/hack/${t}.sh" 1> /dev/null; then
65-
echo -e "${color_red}Running ${t} FAILED${color_norm}"
61+
echo -e "${color_red:?}Running ${t} FAILED${color_norm}"
6662
if ! ${ALL}; then
6763
exit 1
6864
fi
@@ -77,4 +73,4 @@ for t in ${BASH_TARGETS}; do
7773
fi
7874
done
7975

80-
echo -e "${color_green}Update scripts completed successfully${color_norm}"
76+
echo -e "${color_green:?}Update scripts completed successfully${color_norm}"

hack/make-rules/verify.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
21+
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
2222
source "${KUBE_ROOT}/hack/lib/util.sh"
2323

2424
# If KUBE_JUNIT_REPORT_DIR is unset, and ARTIFACTS is set, then have them match.
@@ -80,13 +80,13 @@ QUICK_PATTERNS+=(
8080
"verify-test-owners.sh"
8181
)
8282

83-
EXCLUDED_CHECKS=$(ls ${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true)
84-
QUICK_CHECKS=$(ls ${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true)
83+
while IFS='' read -r line; do EXCLUDED_CHECKS+=("$line"); done < <(ls "${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/}" 2>/dev/null || true)
84+
while IFS='' read -r line; do QUICK_CHECKS+=("$line"); done < <(ls "${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/}" 2>/dev/null || true)
8585
TARGET_LIST=()
8686
IFS=" " read -r -a TARGET_LIST <<< "${WHAT:-}"
8787

8888
function is-excluded {
89-
for e in ${EXCLUDED_CHECKS[@]}; do
89+
for e in "${EXCLUDED_CHECKS[@]}"; do
9090
if [[ $1 -ef "${e}" ]]; then
9191
return
9292
fi
@@ -95,7 +95,7 @@ function is-excluded {
9595
}
9696

9797
function is-quick {
98-
for e in ${QUICK_CHECKS[@]}; do
98+
for e in "${QUICK_CHECKS[@]}"; do
9999
if [[ $1 -ef "${e}" ]]; then
100100
return
101101
fi
@@ -138,9 +138,9 @@ FAILED_TESTS=()
138138

139139
function print-failed-tests {
140140
echo -e "========================"
141-
echo -e "${color_red}FAILED TESTS${color_norm}"
141+
echo -e "${color_red:?}FAILED TESTS${color_norm:?}"
142142
echo -e "========================"
143-
for t in ${FAILED_TESTS[@]}; do
143+
for t in "${FAILED_TESTS[@]}"; do
144144
echo -e "${color_red}${t}${color_norm}"
145145
done
146146
}
@@ -150,10 +150,11 @@ function run-checks {
150150
local -r runner=$2
151151

152152
local t
153-
for t in $(ls ${pattern})
153+
for t in ${pattern}
154154
do
155-
local check_name="$(basename "${t}")"
156-
if [[ ! -z ${WHAT:-} ]]; then
155+
local check_name
156+
check_name="$(basename "${t}")"
157+
if [[ -n ${WHAT:-} ]]; then
157158
if ! is-explicitly-chosen "${check_name}"; then
158159
continue
159160
fi
@@ -168,15 +169,16 @@ function run-checks {
168169
fi
169170
fi
170171
echo -e "Verifying ${check_name}"
171-
local start=$(date +%s)
172+
local start
173+
start=$(date +%s)
172174
run-cmd "${runner}" "${t}" && tr=$? || tr=$?
173-
local elapsed=$(($(date +%s) - ${start}))
175+
local elapsed=$(($(date +%s) - start))
174176
if [[ ${tr} -eq 0 ]]; then
175-
echo -e "${color_green}SUCCESS${color_norm} ${check_name}\t${elapsed}s"
177+
echo -e "${color_green:?}SUCCESS${color_norm} ${check_name}\t${elapsed}s"
176178
else
177179
echo -e "${color_red}FAILED${color_norm} ${check_name}\t${elapsed}s"
178180
ret=1
179-
FAILED_TESTS+=(${t})
181+
FAILED_TESTS+=("${t}")
180182
fi
181183
done
182184
}
@@ -190,7 +192,7 @@ function missing-target-checks {
190192
do
191193
[[ -z "${v}" ]] && continue
192194

193-
FAILED_TESTS+=(${v})
195+
FAILED_TESTS+=("${v}")
194196
ret=1
195197
done
196198
}

0 commit comments

Comments
 (0)