From 173f8e2e4af6b5e0b36ebd4609dc90aec544ac89 Mon Sep 17 00:00:00 2001 From: Ismo Puustinen Date: Tue, 13 Feb 2018 16:31:39 +0200 Subject: [PATCH] hack/lib/golang.sh: use double quotes. It's admittedly extremely unlikely that the host platform name would contain special characters, but still use double quotes to pattern matching. Consider this script: #!/bin/bash bar="foobar" foo="foo*" [[ $bar == $foo ]] && echo "first true" [[ "$bar" == "$foo" ]] && echo "second true" We get the output: first true The plan is to move from first case to the second case to prevent pattern match where there shouldn't be any. --- hack/lib/golang.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index e38fdfd17b5..5f56a81500d 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -401,7 +401,7 @@ kube::golang::place_bins() { # The substitution on platform_src below will replace all slashes with # underscores. It'll transform darwin/amd64 -> darwin_amd64. local platform_src="/${platform//\//_}" - if [[ $platform == $host_platform ]]; then + if [[ "$platform" == "$host_platform" ]]; then platform_src="" rm -f "${THIS_PLATFORM_BIN}" ln -s "${KUBE_OUTPUT_BINPATH}/${platform}" "${THIS_PLATFORM_BIN}" @@ -465,7 +465,7 @@ kube::golang::output_filename_for_binary() { local binary=$1 local platform=$2 local output_path="${KUBE_GOPATH}/bin" - if [[ $platform != $host_platform ]]; then + if [[ "$platform" != "$host_platform" ]]; then output_path="${output_path}/${platform//\//_}" fi local bin=$(basename "${binary}")