fix(build): empty array expansion breaks under set -u on bash 3.2
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user