From 5edcf011f43d955101f32323f24fbb61ac943951 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 17 Oct 2016 13:13:02 +0100 Subject: [PATCH] Better implementation of selecting all apps --- src/freedombone-addremove | 40 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/freedombone-addremove b/src/freedombone-addremove index 048b01d6..bc695e63 100755 --- a/src/freedombone-addremove +++ b/src/freedombone-addremove @@ -56,12 +56,13 @@ do done function show_apps { + select_all_apps=$1 applist="" n=1 app_index=0 for a in "${APPS_AVAILABLE[@]}" do - if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then + if [[ ${APPS_INSTALLED[$app_index]} == "0" && "$select_all_apps" != "add-all" ]]; then applist="$applist $n $a off" else applist="$applist $n $a on" @@ -130,33 +131,14 @@ function remove_apps_selected { } function install_apps_selected { - select_all_apps=$1 # which apps need to be installed? installs="" app_index=0 n=0 - - if [ ! $select_all_apps ]; then - for a in "${APPS_INSTALLED[@]}" - do - if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then - if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then - if [ ${n} -gt 0 ]; then - installs="$installs ${APPS_AVAILABLE[$app_index]}" - else - installs="${APPS_AVAILABLE[$app_index]}" - fi - n=$[n+1] - fi - fi - app_index=$[app_index+1] - done - fi - - if [[ $select_all_apps == "add-all" ]]; then - for a in "${APPS_INSTALLED[@]}" - do - if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then + for a in "${APPS_INSTALLED[@]}" + do + if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then + if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then if [ ${n} -gt 0 ]; then installs="$installs ${APPS_AVAILABLE[$app_index]}" else @@ -164,10 +146,9 @@ function install_apps_selected { fi n=$[n+1] fi - APPS_CHOSEN[$app_index]="1" - app_index=$[app_index+1] - done - fi + fi + app_index=$[app_index+1] + done # if no apps to be installed then don't do anything if [ ${n} -eq 0 ]; then @@ -206,11 +187,12 @@ if [[ ${#APPS_AVAILABLE[@]} == 0 ]]; then exit 1 fi -show_apps +show_apps $1 clear remove_apps_selected + if [[ $1 == "add-all" ]]; then install_apps_selected add-all else