while loop

This commit is contained in:
Heavybullets8 2022-07-25 15:02:47 -06:00
parent 2d5987229b
commit 10cb46633b

View File

@ -9,32 +9,22 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl
update_limit=2 update_limit=2
current_updates=0 current_updates=0
it=0
while true while [[ $it -lt ${#array[@]} ]]
do do
if [[ current_updates -ge "$update_limit" ]]; then jobs=$(jobs -p | wc -l)
sleep 5 if [[ "$jobs" -ge "$update_limit" ]]; then
sleep 3
else else
for i in "${array[@]}" update_apps "${#array[$it]}" &
do
{ update_apps "$i"; (( current_updates-- )) ;} & (( current_updates++ ))
processes+=($!) processes+=($!)
done ((it++))
fi fi
done done
for proc in "${processes[@]}" for proc in "${processes[@]}"
do do
wait "$proc" wait "$proc"