From ab7c4ead05fbfb32fbba1a3fa30908cb9449a5b7 Mon Sep 17 00:00:00 2001 From: Mason Tran Date: Mon, 22 Jan 2024 16:36:05 -0500 Subject: [PATCH] [script] fix bug when running `script/build` with `OT_CMAKE_NINJA_TARGET` containing no RCP targets When running `OT_CMAKE_NINJA_TARGET="ot-cli-ftd" script/build brdXXXXy`, the build script errors with `rcp_targets` being an unbound variable. ```shell + rcp_targets=() + soc_targets=() + for t in '"${OT_CMAKE_NINJA_TARGET[@]}"' + [[ ot-cli-ftd =~ .*rcp.* ]] + soc_targets+=("$t") script/build: line 282: rcp_targets[@]: unbound variable ``` This commit fixes the problem by using a default empty string when `rcp_targets` is empty. --- script/build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/build b/script/build index d1beb1f2..0f690f1f 100755 --- a/script/build +++ b/script/build @@ -279,10 +279,10 @@ main() for t in "${OT_CMAKE_NINJA_TARGET[@]}"; do [[ $t =~ .*rcp.* ]] && rcp_targets+=("$t") || soc_targets+=("$t"); done # Build ot-rcp targets - if contains "ot-rcp-uart" "${rcp_targets[@]}"; then + if contains "ot-rcp-uart" "${rcp_targets[@]-}"; then build_rcp_uart -DEFR32_PLATFORM="${platform}" -DBOARD="${board}" "${options[@]}" fi - if contains "ot-rcp-spi" "${rcp_targets[@]}"; then + if contains "ot-rcp-spi" "${rcp_targets[@]-}"; then build_rcp_spi -DEFR32_PLATFORM="${platform}" -DBOARD="${board}" "${options[@]}" fi # Build soc targets