Description
make verify fails at the test target on a stock macOS machine. hack/test.sh expands an empty array under set -u, which older bash treats as an unbound variable. macOS ships bash 3.2.57 as /bin/bash, and #!/usr/bin/env bash resolves to it unless a newer bash is installed separately.
Steps to reproduce
- On macOS with no third-party bash installed (
/bin/bash --version reports 3.2.57(1)).
- Clone the repository and run
make verify in the repository root.
How to reproduce this behavior without the repository:
$ /bin/bash -c 'set -u; a=(); echo "${a[@]}"'
bash: a[@]: unbound variable
Actual behavior
verify-fmt, verify-modules, verify-generate and lint pass, then:
./hack/test.sh ./cmd/... ./pkg/...
> Unit Tests
./hack/test.sh: line 27: test_flags[@]: unbound variable
make: *** [test] Error 1
hack/test.sh sets nounset (line 4). Outside CI the else branch (lines 22-25) is taken, so test_flags stays empty, and line 27 expands it:
go test ${timeout_flag:+"$timeout_flag"} "$@" "${test_flags[@]}"
Prow is unaffected: there CI and ARTIFACTS are set, so the if branch appends two elements and test_flags is never empty.
Expected behavior
make verify runs the unit tests instead of aborting, on any platform where the documented prerequisites are met. Neither CONTRIBUTING.md nor docs/development.md states an OS or a minimum bash version.
Suggested fix: guard the expansion so it disappears when the array is empty:
go test ${timeout_flag:+"$timeout_flag"} "$@" ${test_flags[@]+"${test_flags[@]}"}
Verified on bash 3.2.57.
PR will follow.
Environment
- Kubernetes version: n/a, fails at build/verify time
- Version of the cloud-provider-stackit:
main at commit 83f9aae
Additional information
- macOS 15.7.7, arm64
/bin/bash 3.2.57(1)-release
- Contributors with Homebrew or MacPorts bash earlier on
PATH get bash 5.x and do not hit this,
which is likely why it went unnoticed.
/kind bug
Description
make verifyfails at thetesttarget on a stock macOS machine.hack/test.shexpands an empty array underset -u, which older bash treats as an unbound variable. macOS ships bash 3.2.57 as/bin/bash, and#!/usr/bin/env bashresolves to it unless a newer bash is installed separately.Steps to reproduce
/bin/bash --versionreports 3.2.57(1)).make verifyin the repository root.How to reproduce this behavior without the repository:
Actual behavior
verify-fmt,verify-modules,verify-generateandlintpass, then:hack/test.shsetsnounset(line 4). Outside CI theelsebranch (lines 22-25) is taken, sotest_flagsstays empty, and line 27 expands it:Prow is unaffected: there
CIandARTIFACTSare set, so theifbranch appends two elements andtest_flagsis never empty.Expected behavior
make verifyruns the unit tests instead of aborting, on any platform where the documented prerequisites are met. NeitherCONTRIBUTING.mdnordocs/development.mdstates an OS or a minimum bash version.Suggested fix: guard the expansion so it disappears when the array is empty:
Verified on bash 3.2.57.
PR will follow.
Environment
mainat commit 83f9aaeAdditional information
/bin/bash3.2.57(1)-releasePATHget bash 5.x and do not hit this,which is likely why it went unnoticed.
/kind bug