From f03730682c28f3ca8ace8d93c685fd240a08ab81 Mon Sep 17 00:00:00 2001 From: Ismo Puustinen Date: Wed, 14 Feb 2018 13:43:44 +0200 Subject: [PATCH] hack/lib/util.sh: do not iterate over ls output. Use globs to make the code more resilient for directory names with special characters or whitespace. --- hack/lib/util.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hack/lib/util.sh b/hack/lib/util.sh index cc7f8945a3f..f65a7d00140 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -459,7 +459,12 @@ kube::util::ensure_godep_version() { kube::util::ensure_no_staging_repos_in_gopath() { kube::util::ensure_single_dir_gopath local error=0 - for repo in $(ls ${KUBE_ROOT}/staging/src/k8s.io); do + for repo_file in "${KUBE_ROOT}"/staging/src/k8s.io/*; do + if [[ ! -d "$repo_file" ]]; then + # not a directory or there were no files + continue; + fi + repo="$(basename "$repo_file")" if [ -e "${GOPATH}/src/k8s.io/${repo}" ]; then echo "k8s.io/${repo} exists in GOPATH. Remove before running godep-save.sh." 1>&2 error=1