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.
This commit is contained in:
Ismo Puustinen 2018-02-13 16:31:39 +02:00
parent c0c888fdc1
commit 173f8e2e4a

View File

@ -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}")