Skip to content

Commit 15ace50

Browse files
committed
ci: cmake-cache expands an empty toolchain argument list the way bash 3.2 (macOS) accepts under set -u
1 parent eaf9d64 commit 15ace50

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎.github/scripts/check-deps-and-qt.sh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ cmake_consumer() {
216216
# identifies is keyed; on Linux the default GCC row lets CMake find its own
217217
# compiler, so the criteria run under mcpp's clang there.
218218
cmake_cache() {
219+
# `${tc[@]+…}`: bash 3.2 (macOS) calls an empty array unbound under `set -u`.
219220
local tc=()
220221
if [ -n "${MSVC_MANAGED:-}" ]; then tc=(--toolchain "$MSVC_MANAGED")
221222
elif ! is_windows && ! is_macos; then tc=(--toolchain "${MCPP_LLVM:-llvm@22.1.8}"); fi
@@ -228,7 +229,7 @@ cmake_cache() {
228229
entries() { find "$MCPP_DEPS_CMAKE_CACHE" -mindepth 2 -maxdepth 2 -type d | wc -l | tr -d ' '; }
229230
configured() { find target -name CMakeCache.txt | grep -q .; }
230231
build() {
231-
"$MCPP" build "${tc[@]}" > "target/ci/$1.log" 2>&1 || { cat "target/ci/$1.log"; fail "the build '$1' failed"; }
232+
"$MCPP" build ${tc[@]+"${tc[@]}"} > "target/ci/$1.log" 2>&1 || { cat "target/ci/$1.log"; fail "the build '$1' failed"; }
232233
}
233234
fresh() { rm -rf target; mkdir -p target/ci; }
234235

@@ -242,7 +243,7 @@ cmake_cache() {
242243
fresh
243244
build taken
244245
configured && fail "a kept installation was configured again"
245-
"$MCPP" run "${tc[@]}" | grep -q '^cmake-consumer: greet says 42$' || fail "the program did not run on a kept installation"
246+
"$MCPP" run ${tc[@]+"${tc[@]}"} | grep -q '^cmake-consumer: greet says 42$' || fail "the program did not run on a kept installation"
246247
[ "$(entries)" = 1 ] || fail "taking an installation kept another one"
247248
echo "ok: a build without target/ took the kept installation and did not configure"
248249

@@ -283,7 +284,7 @@ cmake_cache() {
283284
cd "$ROOT/tests/cmake-not-relocatable"
284285
fresh
285286
build pinned
286-
"$MCPP" run "${tc[@]}" | grep -q '^cmake-not-relocatable: pinned says 7$' || fail "the not-relocatable program did not run"
287+
"$MCPP" run ${tc[@]+"${tc[@]}"} | grep -q '^cmake-not-relocatable: pinned says 7$' || fail "the not-relocatable program did not run"
287288
[ -z "$(find "$MCPP_DEPS_CMAKE_CACHE" -maxdepth 1 -name pinned -type d)" ] ||
288289
[ -z "$(find "$MCPP_DEPS_CMAKE_CACHE/pinned" -mindepth 1)" ] ||
289290
fail "an installation whose files name its own prefix was kept"

0 commit comments

Comments
 (0)