-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix shellcheck failures in /hack/make-rules/update.sh,verify.sh #76420
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,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" | ||
|
||
# If called directly, exit. | ||
|
@@ -32,10 +32,6 @@ fi | |
|
||
SILENT=${SILENT:-true} | ||
ALL=${FORCE_ALL:-false} | ||
V="" | ||
if [[ "${SILENT}" != "true" ]]; then | ||
V="-v" | ||
fi | ||
|
||
trap 'exit 1' SIGINT | ||
|
||
|
@@ -59,10 +55,10 @@ BASH_TARGETS=" | |
update-gofmt" | ||
|
||
for t in ${BASH_TARGETS}; do | ||
echo -e "${color_yellow}Running ${t}${color_norm}" | ||
echo -e "${color_yellow:?}Running ${t}${color_norm:?}" | ||
if ${SILENT} ; then | ||
if ! bash "${KUBE_ROOT}/hack/${t}.sh" 1> /dev/null; then | ||
echo -e "${color_red}Running ${t} FAILED${color_norm}" | ||
echo -e "${color_red:?}Running ${t} FAILED${color_norm}" | ||
if ! ${ALL}; then | ||
exit 1 | ||
fi | ||
|
@@ -77,4 +73,4 @@ for t in ${BASH_TARGETS}; do | |
fi | ||
done | ||
|
||
echo -e "${color_green}Update scripts completed successfully${color_norm}" | ||
echo -e "${color_green:?}Update scripts completed successfully${color_norm}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be coming in from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is shellcheck not seeing this variable come in from that script, is this just not something it's capable of seeing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that shellcheck does not detect such variables and says warning from the following document.
According to the document, I think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is the explanation I was looking for. OK, yeah, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the other "right" way to address this would be to insist all of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I see. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,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/util.sh" | ||
|
||
# If KUBE_JUNIT_REPORT_DIR is unset, and ARTIFACTS is set, then have them match. | ||
|
@@ -80,13 +80,13 @@ QUICK_PATTERNS+=( | |
"verify-test-owners.sh" | ||
) | ||
|
||
EXCLUDED_CHECKS=$(ls ${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true) | ||
QUICK_CHECKS=$(ls ${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true) | ||
while IFS='' read -r line; do EXCLUDED_CHECKS+=("$line"); done < <(ls "${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/}" 2>/dev/null || true) | ||
while IFS='' read -r line; do QUICK_CHECKS+=("$line"); done < <(ls "${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/}" 2>/dev/null || true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When adding only double quotation, EXCLUDED_CHECKS/QUICK_CHECKS are handled as string not array. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. confirmed this works locally |
||
TARGET_LIST=() | ||
IFS=" " read -r -a TARGET_LIST <<< "${WHAT:-}" | ||
|
||
function is-excluded { | ||
for e in ${EXCLUDED_CHECKS[@]}; do | ||
for e in "${EXCLUDED_CHECKS[@]}"; do | ||
if [[ $1 -ef "${e}" ]]; then | ||
return | ||
fi | ||
|
@@ -95,7 +95,7 @@ function is-excluded { | |
} | ||
|
||
function is-quick { | ||
for e in ${QUICK_CHECKS[@]}; do | ||
for e in "${QUICK_CHECKS[@]}"; do | ||
if [[ $1 -ef "${e}" ]]; then | ||
return | ||
fi | ||
|
@@ -138,9 +138,9 @@ FAILED_TESTS=() | |
|
||
function print-failed-tests { | ||
echo -e "========================" | ||
echo -e "${color_red}FAILED TESTS${color_norm}" | ||
echo -e "${color_red:?}FAILED TESTS${color_norm:?}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be coming in from |
||
echo -e "========================" | ||
for t in ${FAILED_TESTS[@]}; do | ||
for t in "${FAILED_TESTS[@]}"; do | ||
echo -e "${color_red}${t}${color_norm}" | ||
done | ||
} | ||
|
@@ -150,10 +150,11 @@ function run-checks { | |
local -r runner=$2 | ||
|
||
local t | ||
for t in $(ls ${pattern}) | ||
for t in ${pattern} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you rename |
||
do | ||
local check_name="$(basename "${t}")" | ||
if [[ ! -z ${WHAT:-} ]]; then | ||
local check_name | ||
check_name="$(basename "${t}")" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if [[ -n ${WHAT:-} ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if ! is-explicitly-chosen "${check_name}"; then | ||
continue | ||
fi | ||
|
@@ -168,15 +169,16 @@ function run-checks { | |
fi | ||
fi | ||
echo -e "Verifying ${check_name}" | ||
local start=$(date +%s) | ||
local start | ||
start=$(date +%s) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
run-cmd "${runner}" "${t}" && tr=$? || tr=$? | ||
local elapsed=$(($(date +%s) - ${start})) | ||
local elapsed=$(($(date +%s) - start)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if [[ ${tr} -eq 0 ]]; then | ||
echo -e "${color_green}SUCCESS${color_norm} ${check_name}\t${elapsed}s" | ||
echo -e "${color_green:?}SUCCESS${color_norm} ${check_name}\t${elapsed}s" | ||
else | ||
echo -e "${color_red}FAILED${color_norm} ${check_name}\t${elapsed}s" | ||
ret=1 | ||
FAILED_TESTS+=(${t}) | ||
FAILED_TESTS+=("${t}") | ||
fi | ||
done | ||
} | ||
|
@@ -190,7 +192,7 @@ function missing-target-checks { | |
do | ||
[[ -z "${v}" ]] && continue | ||
|
||
FAILED_TESTS+=(${v}) | ||
FAILED_TESTS+=("${v}") | ||
ret=1 | ||
done | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #74877,
godep-restore.sh" ${V}
was deleted and I could not find scripts which use "V". So I deleted these lines.