Merge pull request #113190 from BenTheElder/shell-fixups

assorted small shell script fixes
This commit is contained in:
Kubernetes Prow Robot
2022-10-20 03:34:57 -07:00
committed by GitHub
8 changed files with 30 additions and 20 deletions

View File

@@ -18,11 +18,12 @@
# A set of helpers for tests
readonly reset=$(tput sgr0)
readonly bold=$(tput bold)
readonly black=$(tput setaf 0)
readonly red=$(tput setaf 1)
readonly green=$(tput setaf 2)
reset=$(tput sgr0)
bold=$(tput bold)
black=$(tput setaf 0)
red=$(tput setaf 1)
green=$(tput setaf 2)
readonly reset bold black red green
kube::test::clear_all() {
if kube::test::if_supports_resource "rc" ; then

View File

@@ -603,11 +603,9 @@ function kube::util::list_staging_repos() {
# Determines if docker can be run, failures may simply require that the user be added to the docker group.
function kube::util::ensure_docker_daemon_connectivity {
IFS=" " read -ra DOCKER <<< "${DOCKER_OPTS}"
# Expand ${DOCKER[@]} only if it's not unset. This is to work around
# Bash 3 issue with unbound variable.
DOCKER=(docker ${DOCKER[@]:+"${DOCKER[@]}"})
if ! "${DOCKER[@]}" info > /dev/null 2>&1 ; then
DOCKER_OPTS=${DOCKER_OPTS:-""}
IFS=" " read -ra docker_opts <<< "${DOCKER_OPTS}"
if ! docker "${docker_opts[@]:+"${docker_opts[@]}"}" info > /dev/null 2>&1 ; then
cat <<'EOF' >&2
Can't connect to 'docker' daemon. please fix and retry.

View File

@@ -18,8 +18,9 @@ set -o errexit
set -o nounset
set -o pipefail
readonly red=$(tput setaf 1)
readonly reset=$(tput sgr0)
red=$(tput setaf 1)
reset=$(tput sgr0)
readonly red reset
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
ALL_TARGETS=$(make -C "${KUBE_ROOT}" PRINT_HELP=y -rpn | sed -n -e '/^$/ { n ; /^[^ .#][^ ]*:/ { s/:.*$// ; p ; } ; }' | sort)

View File

@@ -41,7 +41,8 @@ fi
pushd "${KUBE_ROOT}" > /dev/null
# Setup a tmpdir to hold generated scripts and results
readonly tmpdir=$(mktemp -d -t verify-e2e-test-ownership.XXXX)
tmpdir=$(mktemp -d -t verify-e2e-test-ownership.XXXX)
readonly tmpdir
trap 'rm -rf ${tmpdir}' EXIT
# input

View File

@@ -70,7 +70,7 @@ ret=0
pushd "${KUBE_ROOT}" > /dev/null 2>&1
# Test for diffs
_output=""
for file in ${TARGET_FILES[*]}; do
for file in "${TARGET_FILES[@]}"; do
_output="${_output}$(diff -Naupr -I 'Auto generated by' "${KUBE_ROOT}/${file}" "${_kubetmp}/${file}")" || ret=1
done

View File

@@ -39,6 +39,10 @@ disabled=(
# this lint disallows non-constant source, which we use extensively without
# any known bugs
1090
# this lint warns when shellcheck cannot find a sourced file
# this wouldn't be a bad idea to warn on, but it fails on lots of path
# dependent sourcing, so just disable enforcing it
1091
# this lint prefers command -v to which, they are not the same
2230
)