From: Steven Baltakatei Sandoval Date: Tue, 20 Sep 2022 20:24:08 +0000 (+0000) Subject: feat(u/bktemp-checkAppFileDir):Fix zero-length string bug X-Git-Tag: 0.5.1~6 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/d7ffba91c60ad9ffc96fe6176117a0d8543d02cf feat(u/bktemp-checkAppFileDir):Fix zero-length string bug - Note: checkfile() had "bad array subscript" error when fed a zero-length string as input. --- 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