diff --git a/hack/get-ldflags.sh b/hack/get-ldflags.sh index 9f3fe07b..c634e864 100755 --- a/hack/get-ldflags.sh +++ b/hack/get-ldflags.sh @@ -1,10 +1,8 @@ #!/usr/bin/env bash +set -euo pipefail +ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" -set -o errexit -set -o nounset -set -o pipefail - -KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -source "${KUBE_ROOT}/hack/lib/version.sh" +KUBE_ROOT="${ROOT}" # required by `hack/lib/version.sh` +source "${ROOT}/hack/lib/version.sh" kube::version::ldflags diff --git a/hack/module.sh b/hack/module.sh index c870caec..b9c24821 100755 --- a/hack/module.sh +++ b/hack/module.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash set -euo pipefail - -root_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" function tidy_cmd() { echo 'go mod tidy -v' @@ -48,7 +47,7 @@ function with_modules() { local cmd_function="${1}" cmd="$(${cmd_function})" - pushd "${root_dir}" + pushd "${ROOT}" for mod_file in $(find . -maxdepth 4 -name go.mod | sort); do mod_dir="$(dirname "${mod_file}")" ( diff --git a/hack/test-unit.sh b/hack/test-unit.sh index 5d987d46..1100c91e 100755 --- a/hack/test-unit.sh +++ b/hack/test-unit.sh @@ -3,6 +3,6 @@ # Copyright 2020 VMware, Inc. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail -ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")" +ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" "$ROOT/hack/module.sh" unittest \ No newline at end of file diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 9e056a4e..c1b1b5eb 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -3,8 +3,8 @@ # Copyright 2020 VMware, Inc. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail +ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" -ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")" BASE_PKG="github.com/suzerain-io/placeholder-name" CODEGEN_IMAGE=${CODEGEN_IMAGE:-gcr.io/tanzu-user-authentication/k8s-code-generator-1.19:latest} diff --git a/hack/update.sh b/hack/update.sh index ab5a52d4..5d070127 100755 --- a/hack/update.sh +++ b/hack/update.sh @@ -3,7 +3,7 @@ # Copyright 2020 VMware, Inc. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail -ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")" +ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" "$ROOT/hack/module.sh" tidy "$ROOT/hack/update-codegen.sh" \ No newline at end of file diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh index dc3bfae1..f8cdb3a1 100755 --- a/hack/verify-codegen.sh +++ b/hack/verify-codegen.sh @@ -15,8 +15,7 @@ # limitations under the License. set -euo pipefail - -ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" DIFFROOT="${ROOT}/kubernetes" TMP_DIFFROOT="${ROOT}/_tmp/kubernetes" diff --git a/hack/verify.sh b/hack/verify.sh index 375242d1..7a9ea7f4 100755 --- a/hack/verify.sh +++ b/hack/verify.sh @@ -3,7 +3,7 @@ # Copyright 2020 VMware, Inc. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail -ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")" +ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" "$ROOT/hack/module.sh" lint "$ROOT/hack/verify-codegen.sh"