util/abuild: fix TODO and update targets variable to an array
Use an array instead of a variable as suggested by the TODO, so we can remove the shellcheck disable and fix the warning. Change-Id: I5e872ebe350f339b932a711fe7f6a68743f002ed Signed-off-by: Martin Roth <gaumless@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/87379 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
parent
902288db22
commit
64fe6fd94a
1 changed files with 17 additions and 9 deletions
|
|
@ -176,22 +176,30 @@ mainboard_vendor()
|
|||
# If a directory contains multiple boards, returns them all.
|
||||
normalize_target()
|
||||
{
|
||||
# TODO: Change 'targets' variable to an array
|
||||
local targets
|
||||
local target_input=$1
|
||||
local -a targets=() # Initialize as an empty array
|
||||
local VARIANT_UC
|
||||
local i
|
||||
|
||||
VARIANT_UC=$(echo "${variant}" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
|
||||
|
||||
targets=$(get_mainboards "$1")
|
||||
if [[ -n "${targets}" ]]; then
|
||||
# shellcheck disable=SC2086
|
||||
targets="$(grep "${VARIANT_UC}\$" <<< ${targets})"
|
||||
echo "${targets}"
|
||||
# Read output of get_mainboards into the targets array
|
||||
mapfile -t targets < <(get_mainboards "${target_input}")
|
||||
if [[ ${#targets[@]} -gt 0 ]]; then
|
||||
# Filter the array using grep
|
||||
mapfile -t targets < <(printf '%s\n' "${targets[@]}" | grep "${VARIANT_UC}\$")
|
||||
# Print the filtered targets, one per line
|
||||
if [[ ${#targets[@]} -gt 0 ]]; then
|
||||
printf '%s\n' "${targets[@]}"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
targets=$(echo "$1" | tr ',' ' ')
|
||||
for i in ${targets}; do
|
||||
# Handle comma-separated input string
|
||||
IFS=',' read -ra targets <<< "${target_input}"
|
||||
for i in "${targets[@]}"; do
|
||||
# Trim whitespace if necessary (read -ra might include it)
|
||||
i=$(echo "$i" | xargs)
|
||||
if [[ -n "$(mainboard_directory "${i}")" ]]; then
|
||||
printf "%s\n" "${i}"
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue