From 1d61a0aed0113df2ada6c6406ae035e3d8280420 Mon Sep 17 00:00:00 2001 From: Kubilay Kocak Date: Fri, 2 Dec 2022 22:24:17 +0000 Subject: [PATCH 5/7] Fix variable assignments and usage I was in ports Makefile not bash mode. --- scripts/build_go.sh | 12 ++++++------ scripts/lib.sh | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) mode change 100644 => 100755 scripts/lib.sh diff --git a/scripts/build_go.sh b/scripts/build_go.sh index 300bf764..77b6e520 100755 --- a/scripts/build_go.sh +++ b/scripts/build_go.sh @@ -27,11 +27,11 @@ set -euo pipefail # shellcheck source=scripts/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" -# Allow specifying go command via environment -GOCMD?=go +#Allow specifying go command via environment +GOCMD="${GOCMD:-go}" # Allow specifying/overriding GETOPT via environment -GETOPT?=getopt +GETOPT="${GETOPT:-getopt}" version="" os="${GOOS:-linux}" @@ -41,7 +41,7 @@ sign_darwin="${CODER_SIGN_DARWIN:-0}" output_path="" agpl="${CODER_BUILD_AGPL:-0}" -args="$($(GETOPT) -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin -- "$@")" +args="$(${GETOPT} -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin -- "$@")" eval set -- "$args" while true; do case "$1" in @@ -93,7 +93,7 @@ if [[ "$version" == "" ]]; then fi # Check dependencies -dependencies go +dependencies ${GOCMD} if [[ "$sign_darwin" == 1 ]]; then dependencies rcodesign requiredenvs AC_CERTIFICATE_FILE AC_CERTIFICATE_PASSWORD_FILE @@ -132,7 +132,7 @@ cmd_path="./enterprise/cmd/coder" if [[ "$agpl" == 1 ]]; then cmd_path="./cmd/coder" fi -CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" GOARM="$arm_version" $(GOCMD) build \ +CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" GOARM="$arm_version" ${GOCMD} build \ "${build_args[@]}" \ "$cmd_path" 1>&2 diff --git a/scripts/lib.sh b/scripts/lib.sh old mode 100644 new mode 100755 index 876b99c7..6463aa4f --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -34,10 +34,10 @@ SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" PROJECT_ROOT="$(cd "$SCRIPT_DIR" && realpath "$(git rev-parse --show-toplevel)")" # Allow specifying/overriding make command via environment -MAKECMD?=make +MAKECMD="${MAKECMD:-make}" # Allow specifying/overriding GETOPT via environment -GETOPT?=getopt +GETOPT="${GETOPT:-getopt}" # pushd is a silent alternative to the real pushd shell command. pushd() { @@ -155,7 +155,7 @@ if [[ "${CODER_LIBSH_NO_CHECK_DEPENDENCIES:-}" != *t* ]]; then fi # BSD getopt (which is installed by default on Macs) is not supported. - if [[ "$($(GETOPT) --version)" == *--* ]]; then + if [[ "$(${GETOPT} --version)" == *--* ]]; then libsh_bad_dependencies=1 log "ERROR: You need GNU getopt to run the scripts in the Coder repo." if isdarwin; then @@ -176,7 +176,7 @@ if [[ "${CODER_LIBSH_NO_CHECK_DEPENDENCIES:-}" != *t* ]]; then # We have to disable pipefail temporarily to avoid ERRPIPE errors when # piping into `head -n1`. set +o pipefail - make_version="$($(MAKECMD) --version 2>/dev/null | head -n1 | grep -oE '([[:digit:]]+\.){1,2}[[:digit:]]+')" + make_version="$(${MAKECMD} --version 2>/dev/null | head -n1 | grep -oE '([[:digit:]]+\.){1,2}[[:digit:]]+')" set -o pipefail if [[ ${make_version//.*/} -lt 4 ]]; then libsh_bad_dependencies=1 -- 2.38.1