From 4d14244133fa943250fa619aa6677d1954b859c2 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 28 Jan 2023 13:48:17 +0100 Subject: [PATCH] fixed array. Choosing what containers to update was broken due to array mistakenly was a list. Now fixed and should work fine, no matter what order specified eg. `5,1,2,7` --- experimental_dockcheck.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/experimental_dockcheck.sh b/experimental_dockcheck.sh index b03871a..2c8aa77 100644 --- a/experimental_dockcheck.sh +++ b/experimental_dockcheck.sh @@ -99,19 +99,18 @@ done } choosecontainers() { -while [[ "$ChoiceClean" =~ [A-Za-z] || -z "$ChoiceClean" ]]; do +while [[ "$ChoiceClean" =~ [A-Za-z] || -z "$ChoiceClean" ]]; do printf "What containers do you like to update? \n" options - read -p 'Enter number(s) separated by ,(comma) : ' Choice + read -p 'Enter number(s) separated by , : ' Choice if [ "$Choice" == "0" ] ; then SelectedUpdates=( ${NumberedUpdates[@]:1} ) ChoiceClean=$(echo $Choice|sed 's/[,.:;]/ /g') else ChoiceClean=$(echo $Choice|sed 's/[,.:;]/ /g') - SelectedUpdates=$(\ - for s in $ChoiceClean; do - printf "%s\n" "${NumberedUpdates[${s}]}" - done) + for s in $ChoiceClean; do + SelectedUpdates+=( ${NumberedUpdates[$s]} ) + done fi done printf "\nYou've SelectedUpdates:\n" @@ -141,4 +140,5 @@ if [ -n "$GotUpdates" ] ; then else printf "\nNo updates available, exiting.\n" fi + exit 0