+declare -Ag appRollCall # Associative array for storing app status
+declare -Ag fileRollCall # Associative array for storing file status
+declare -Ag dirRollCall # Associative array for storing dir status
+
+#===BEGIN Declare local script functions===
+checkapp() {
+ # Desc: If arg is a command, save result in assoc array 'appRollCall'
+ # Usage: checkapp arg1 arg2 arg3 ...
+ # Input: global assoc. array 'appRollCall'
+ # Output: adds/updates key(value) to global assoc array 'appRollCall'
+ local returnState
+ #echo "DEBUG:$(date +%S.%N)..Starting checkapp function."
+ #echo "DEBUG:args: $@"
+ #echo "DEBUG:returnState:$returnState"
+
+ #===Process Args===
+ for arg in "$@"; do
+ #echo "DEBUG:processing arg:$arg"
+ if command -v "$arg" 1>/dev/null 2>&1; then # Check if arg is a valid command
+ appRollCall[$arg]="true";
+ #echo "DEBUG:appRollCall[$arg]:"${appRollCall[$arg]}
+ if ! [ "$returnState" = "false" ]; then returnState="true"; fi
+ else
+ appRollCall[$arg]="false"; returnState="false";
+ fi
+ done
+
+ #for key in "${!appRollCall[@]}"; do echo "DEBUG:$key => ${appRollCall[$key]}"; done
+ #echo "DEBUG:evaluating returnstate. returnState:"$returnState
+
+ #===Determine function return code===
+ if [ "$returnState" = "true" ]; then
+ #echo "DEBUG:checkapp returns true for $arg";
+ return 0;
+ else
+ #echo "DEBUG:checkapp returns false for $arg";
+ return 1;
+ fi
+} # Check that app exists
+checkfile() {
+ # Desc: If arg is a file path, save result in assoc array 'fileRollCall'
+ # Usage: checkfile arg1 arg2 arg3 ...
+ # Input: global assoc. array 'fileRollCall'
+ # Output: adds/updates key(value) to global assoc array 'fileRollCall';
+ # Output: returns 0 if app found, 1 otherwise
+ local returnState
+
+ #===Process Args===
+ for arg in "$@"; do
+ #echo "DEBUG:processing arg:$arg"
+ if [ -f "$arg" ]; then
+ fileRollCall["$arg"]="true";
+ #echo "DEBUG:fileRollCall[\"$arg\"]:"${fileRollCall["$arg"]}
+ if ! [ "$returnState" = "false" ]; then returnState="true"; fi
+ else
+ fileRollCall["$arg"]="false"; returnState="false";
+ fi
+ done
+
+ #for key in "${!fileRollCall[@]}"; do echo "DEBUG:fileRollCall key [$key] is:${fileRollCall[$key]}"; done
+ #echo "DEBUG:evaluating returnstate. returnState:"$returnState
+
+ #===Determine function return code===
+ if [ "$returnState" = "true" ]; then
+ #echo "DEBUG:checkapp returns true for $arg";
+ return 0;
+ else
+ #echo "DEBUG:checkapp returns false for $arg";
+ return 1;
+ fi
+} # Check that file exists
+checkdir() {
+ # Desc: If arg is a dir path, save result in assoc array 'dirRollCall'
+ # Usage: checkdir arg1 arg2 arg3 ...
+ # Input: global assoc. array 'dirRollCall'
+ # Output: adds/updates key(value) to global assoc array 'dirRollCall';
+ # Output: returns 0 if app found, 1 otherwise
+ local returnState
+
+ #===Process Args===
+ for arg in "$@"; do
+ #echo "DEBUG:processing arg:$arg"
+ if [ -d "$arg" ]; then
+ dirRollCall["$arg"]="true";
+ #echo "DEBUG:dirRollCall[\"$arg\"]:"${dirRollCall["$arg"]}
+ if ! [ "$returnState" = "false" ]; then returnState="true"; fi
+ elif [ "$arg" = "" ]; then
+ dirRollCall["$arg"]="false"; returnState="false";
+ else
+ returnState="false";
+ fi
+ done
+
+ #for key in "${!dirRollCall[@]}"; do echo "DEBUG:dirRollCall key [$key] is:${dirRollCall[$key]}"; done
+ #echo "DEBUG:evaluating returnstate. returnState:"$returnState
+
+ #===Determine function return code===
+ if [ "$returnState" = "true" ]; then
+ #echo "DEBUG:checkapp returns true for $arg";
+ return 0;
+ else
+ #echo "DEBUG:checkapp returns false for $arg";
+ return 1;
+ fi
+} # Check that dir exists
+