From 43e9e1ec677d6bffa3c590464992a7644bd203f5 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Tue, 8 Sep 2026 19:25:22 +0200 Subject: [PATCH] Support macOS Bash 3.2 in compile scripts --- compile-app.sh | 6 +++--- compile-firmware.sh | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/compile-app.sh b/compile-app.sh index ae5a7319..c89bcfef 100755 --- a/compile-app.sh +++ b/compile-app.sh @@ -33,7 +33,7 @@ if [ "${#ALL_APPS[@]}" -eq 0 ]; then fi # --- select targets --- -if [ "$#" -eq 0 ] || [ "${1,,}" = "all" ]; then +if [ "$#" -eq 0 ] || [[ "${1:-}" == [Aa][Ll][Ll] ]]; then TARGETS=("${ALL_APPS[@]}") else TARGETS=() @@ -56,7 +56,7 @@ mkdir -p "$OUT_DIR" # Give the container a pseudo-TTY when we are interactive, so build.sh's # single-line [k/3] progress refreshes in place (same trick as the firmware # build gives Ninja). Batch/redirected runs stay plain and line-oriented. -TTY_ARGS=(); [[ -t 1 ]] && TTY_ARGS=(-t) +TTY_ARG=""; [[ -t 1 ]] && TTY_ARG="-t" echo echo "🚀 Building overlay apps" @@ -69,7 +69,7 @@ fail=0 read_u32le() { od -An -tx1 -j"$2" -N4 "$1" | awk '{printf "0x%s%s%s%s",$4,$3,$2,$1}'; } for app in "${TARGETS[@]}"; do - if docker run --rm "${TTY_ARGS[@]}" -u "$(id -u):$(id -g)" \ + if docker run --rm ${TTY_ARG:+"$TTY_ARG"} -u "$(id -u):$(id -g)" \ -v "$PWD":/work -w "/work/$APPS_DIR/$app" \ -e PATH="/opt/toolchain/bin:/usr/bin:/bin" -e APP_VMA="$APP_VMA" \ "$IMAGE" bash ./build.sh; then diff --git a/compile-firmware.sh b/compile-firmware.sh index a2653570..6e997594 100755 --- a/compile-firmware.sh +++ b/compile-firmware.sh @@ -63,29 +63,32 @@ RESULT_RAM_SIZES=() run_preset_build() { local preset="$1" - local -a docker_tty_args=() + local docker_tty_arg="" # Give Ninja a pseudo-terminal for an interactive single-preset build. This # lets it refresh its [current/total] progress on one line. Batch/redirected # builds keep plain line-oriented output suitable for logs and CI. if (( INTERACTIVE && ! QUIET )); then - docker_tty_args=(-t) + docker_tty_arg="-t" fi - docker run --rm "${docker_tty_args[@]}" \ + # The ${var:+...} and ${array[@]+...} forms avoid expanding an empty array, + # which Bash 3.2 treats as an unbound variable when nounset is enabled. + docker run --rm ${docker_tty_arg:+"$docker_tty_arg"} \ -u "$(id -u):$(id -g)" \ -v "$PWD":/src -w /src "$IMAGE" \ bash -c 'which arm-none-eabi-gcc && arm-none-eabi-gcc --version && cmake --fresh --preset "$1" "${@:2}" && cmake --build --preset "$1" -j' \ - bash "$preset" "${EXTRA_ARGS[@]}" + bash "$preset" ${EXTRA_ARGS[@]+"${EXTRA_ARGS[@]}"} } build_preset() { local preset="$1" local preset_slug log_file bin_file flash_size ram_size status - preset_slug="${preset,,}" + # macOS ships Bash 3.2, which does not support Bash 4's ${var,,} syntax. + preset_slug="$(printf '%s' "$preset" | tr '[:upper:]' '[:lower:]')" log_file="$(mktemp)" bin_file=""