From 859a716b5defb6e0459388731cc9291f6ce4577b Mon Sep 17 00:00:00 2001 From: Andre Padez Date: Fri, 14 Aug 2026 23:17:11 +0100 Subject: [PATCH] fix(build): empty array expansion breaks under set -u on bash 3.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/build-android.sh died with 'MINIFY_ARGS[@]: unbound variable' before Gradle ever ran. macOS ships bash 3.2, where expanding an EMPTY array under set -u is itself an unbound-variable error — the array is declared and empty, which is the normal case, since MINIFY defaults to off. The monorepo's copy of this code has the same bare expansion and works, because that script does not set -u. So the bug was latent there and became real the moment a stricter copy ran it. Co-Authored-By: Claude Opus 5 --- scripts/build-android.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/build-android.sh b/scripts/build-android.sh index 8cf1345..297bb1d 100755 --- a/scripts/build-android.sh +++ b/scripts/build-android.sh @@ -49,6 +49,9 @@ ABIS="${ABIS:-arm64-v8a}" # Expo both do that, and so does the gomobile binding layer. The build still succeeds; the app crashes # on the device. This cannot be verified by looking at a file size, and it must not become the default # until a build with it has been opened on a real phone, connected to a tailnet, and used. +# Expanded below as ${MINIFY_ARGS[@]+...} rather than bare: macOS ships bash 3.2, where expanding an +# EMPTY array under `set -u` is itself an unbound-variable error. The monorepo's copy of this script +# survives the bare form only because it does not set -u — the bug was latent there and real here. MINIFY_ARGS=() if [[ "${MINIFY:-0}" == "1" ]]; then MINIFY_ARGS=(-Pandroid.enableMinifyInReleaseBuilds=true) @@ -57,7 +60,7 @@ fi # assembleRelease, always. A debug build needs Metro attached and behaves differently from what ships, # so testing it answers the wrong question. if ! (cd android && ./gradlew :app:assembleRelease -PreactNativeArchitectures="$ABIS" \ - "${MINIFY_ARGS[@]}" --console=plain) >>"$log" 2>&1; then + ${MINIFY_ARGS[@]+"${MINIFY_ARGS[@]}"} --console=plain) >>"$log" 2>&1; then echo "GRADLE FAILED — $log"; exit 1 fi