From ee0c47c3ff329f0a9748366715a8a615c9564a19 Mon Sep 17 00:00:00 2001 From: pabera <1260686+pabera@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:21:59 +0100 Subject: [PATCH] fix: some iterations did not work --- installation/components/setup_hifiberry.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/installation/components/setup_hifiberry.sh b/installation/components/setup_hifiberry.sh index 1b299cc00..8d4139bc0 100644 --- a/installation/components/setup_hifiberry.sh +++ b/installation/components/setup_hifiberry.sh @@ -33,8 +33,8 @@ where can be 'enable' or 'disable'" return 0;; *) echo "'$2' is not a valid option. You can choose from:" - for key in "${!hifiberry_descriptions[@]}"; do - description="${hifiberry_descriptions[$key]}" + for key in "${!hifiberry_map[@]}"; do + description="${hifiberry_map[$key]}" echo "$key) $description" done echo "Example usage: ./${script_name} enable hifiberry-dac" @@ -77,20 +77,24 @@ check_existing_hifiberry() { } prompt_board_list() { + board_count=${#hifiberry_map[@]} + + counter=1 echo "Select your HiFiBerry board:" - for key in "${!hifiberry_descriptions[@]}"; do - description="${hifiberry_descriptions[$key]}" - echo "$key) $description" + for key in "${!hifiberry_map[@]}"; do + description="${hifiberry_map[$key]}" + echo "$counter) $description" + ((counter++)) done - read -p "Enter your choice (0-9): " choice + read -p "Enter your choice (1-$board_count): " choice case $choice in [0]) disable_hifiberry; exit 1;; - [1-9]) - selected_board="${hifiberry_descriptions[$choice]}"; + [1-$board_count]) + selected_board="${hifiberry_map[$choice]}"; enable_hifiberry "$selected_board"; return 0;; *)