Skip to content

Commit 90a939e

Browse files
authored
Merge pull request kubernetes#76131 from SataQiu/fix-hack-20190404
Fix shellcheck failures of hack/lib/logging.sh hack/lib/protoc.sh
2 parents 969c110 + 4231fa0 commit 90a939e

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

hack/.shellcheck_failures

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
./hack/ginkgo-e2e.sh
2929
./hack/grab-profiles.sh
3030
./hack/lib/init.sh
31-
./hack/lib/logging.sh
32-
./hack/lib/protoc.sh
3331
./hack/lib/swagger.sh
3432
./hack/lib/test.sh
3533
./hack/lib/version.sh

hack/lib/logging.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ KUBE_VERBOSE="${KUBE_VERBOSE:-5}"
2020
# Handler for when we exit automatically on an error.
2121
# Borrowed from https://gist.github.com/ahendrix/7030300
2222
kube::log::errexit() {
23-
local err="${PIPESTATUS[@]}"
23+
local err="${PIPESTATUS[*]}"
2424

2525
# If the shell we are in doesn't have errexit set (common in subshells) then
2626
# don't dump stacks.
@@ -60,7 +60,7 @@ kube::log::stack() {
6060
if [[ ${#FUNCNAME[@]} -gt ${stack_skip} ]]; then
6161
echo "Call stack:" >&2
6262
local i
63-
for ((i=1 ; i <= ${#FUNCNAME[@]} - ${stack_skip} ; i++))
63+
for ((i=1 ; i <= ${#FUNCNAME[@]} - stack_skip ; i++))
6464
do
6565
local frame_no=$((i - 1 + stack_skip))
6666
local source_file=${BASH_SOURCE[${frame_no}]}

hack/lib/protoc.sh

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

2121
# The root of the build/dist directory
22-
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../.." && pwd -P)"
22+
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
2323
source "${KUBE_ROOT}/hack/lib/init.sh"
2424

2525
# Generates $1/api.pb.go from the protobuf file $1/api.proto
@@ -35,8 +35,8 @@ function kube::protoc::generate_proto() {
3535
kube::protoc::check_protoc
3636

3737
local package=${1}
38-
kube::protoc::protoc ${package}
39-
kube::protoc::format ${package}
38+
kube::protoc::protoc "${package}"
39+
kube::protoc::format "${package}"
4040
}
4141

4242
# Checks that the current protoc version is at least version 3.0.0-beta1
@@ -62,7 +62,7 @@ function kube::protoc::protoc() {
6262
PATH="${gogopath}:${PATH}" protoc \
6363
--proto_path="${package}" \
6464
--proto_path="${KUBE_ROOT}/vendor" \
65-
--gogo_out=plugins=grpc:${package} ${package}/api.proto
65+
--gogo_out=plugins=grpc:"${package}" "${package}/api.proto"
6666
}
6767

6868
# Formats $1/api.pb.go, adds the boilerplate comments and run gofmt on it
@@ -71,20 +71,20 @@ function kube::protoc::format() {
7171
local package=${1}
7272

7373
# Update boilerplate for the generated file.
74-
echo "$(cat hack/boilerplate/boilerplate.generatego.txt ${package}/api.pb.go)" > ${package}/api.pb.go
74+
cat hack/boilerplate/boilerplate.generatego.txt "${package}/api.pb.go" > tmpfile && mv tmpfile "${package}/api.pb.go"
7575

7676
# Run gofmt to clean up the generated code.
7777
kube::golang::verify_go_version
78-
gofmt -l -s -w ${package}/api.pb.go
78+
gofmt -l -s -w "${package}/api.pb.go"
7979
}
8080

8181
# Compares the contents of $1 and $2
8282
# Echo's $3 in case of error and exits 1
8383
function kube::protoc::diff() {
8484
local ret=0
85-
diff -I "gzipped FileDescriptorProto" -I "0x" -Naupr ${1} ${2} || ret=$?
85+
diff -I "gzipped FileDescriptorProto" -I "0x" -Naupr "${1}" "${2}" || ret=$?
8686
if [[ ${ret} -ne 0 ]]; then
87-
echo ${3}
87+
echo "${3}"
8888
exit 1
8989
fi
9090
}

0 commit comments

Comments
 (0)