From 391cd856c1e453eafc7165d2004f01eba0022601 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 27 Aug 2014 20:33:58 -0700 Subject: [PATCH] Use `cd` and `pwd` in a subshell to define ${KUBE_REPO_ROOT} The old method (using `readlink`) was convoluted and not portable. We can achieve the same result using only bash builtins. Signed-off-by: Filipe Brandenburger --- hack/config-go.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hack/config-go.sh b/hack/config-go.sh index d8c11f3d472..719b5e0b25b 100644 --- a/hack/config-go.sh +++ b/hack/config-go.sh @@ -103,16 +103,15 @@ kube::setup_go_environment() { # KUBE_TARGET - Path where output Go files are saved. # KUBE_GO_PACKAGE - Full name of the Kubernetes Go package. -KUBE_REPO_ROOT=$(dirname "${BASH_SOURCE:-$0}")/.. -if [[ "${OSTYPE:-}" == *darwin* ]]; then - # Make the path absolute if it is not. - if [[ "${KUBE_REPO_ROOT}" != /* ]]; then - KUBE_REPO_ROOT=${PWD}/${KUBE_REPO_ROOT} - fi -else - # Resolve symlinks. - KUBE_REPO_ROOT=$(readlink -f "${KUBE_REPO_ROOT}") -fi +# Make ${KUBE_REPO_ROOT} an absolute path. +KUBE_REPO_ROOT=$( + set -eu + unset CDPATH + scripts_dir=$(dirname "${BASH_SOURCE[0]}") + cd "${scripts_dir}" + cd .. + pwd +) export KUBE_REPO_ROOT KUBE_TARGET="${KUBE_REPO_ROOT}/output/go"