From d7ffba91c60ad9ffc96fe6176117a0d8543d02cf Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Tue, 20 Sep 2022 20:24:08 +0000 Subject: [PATCH] feat(u/bktemp-checkAppFileDir):Fix zero-length string bug - Note: checkfile() had "bad array subscript" error when fed a zero-length string as input. --- unitproc/bktemp-checkAppFileDir | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unitproc/bktemp-checkAppFileDir b/unitproc/bktemp-checkAppFileDir index d2f58d2..94afbd8 100644 --- a/unitproc/bktemp-checkAppFileDir +++ b/unitproc/bktemp-checkAppFileDir @@ -38,7 +38,7 @@ checkapp() { checkfile() { # Desc: If arg is a file path, save result in assoc array 'fileRollCall' # Usage: checkfile arg1 arg2 arg3 ... - # Version: 0.1.1 + # Version: 0.1.2 # Input: global assoc. array 'fileRollCall' # Output: adds/updates key(value) to global assoc array 'fileRollCall'; # Output: returns 0 if app found, 1 otherwise @@ -50,6 +50,8 @@ checkfile() { if [ -f "$arg" ]; then fileRollCall["$arg"]="true"; if ! [ "$returnState" = "false" ]; then returnState="true"; fi; + elif [ -z "$arg" ]; then + fileRollCall["(no name)"]="false"; returnState="false"; else fileRollCall["$arg"]="false"; returnState="false"; fi; @@ -180,6 +182,8 @@ if ! displayMissing 1>/dev/null 2>&1; then echo "Something is missing!"; displayMissing; fi; +sleep 1; +myFile=""; if ! checkfile "$myFile"; then echo "An empty argument provided:$myFile"; displayMissing; fi; #==END sample code== # Author: Steven Baltaktei Sandoval -- 2.30.2