From: Steven Baltakatei Sandoval Date: Tue, 18 Jan 2022 01:10:03 +0000 (+0000) Subject: feat(u/bktemp-checkAppFileDir):displayMissing exit code X-Git-Tag: 0.5.0~24 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/b8f798aa115328694754d1c343127440c270a83f?ds=inline;hp=-c feat(u/bktemp-checkAppFileDir):displayMissing exit code - Note: displayMissing() function returns with exit code 0 if nothing missing, 1 otherwise. --- b8f798aa115328694754d1c343127440c270a83f diff --git a/unitproc/bktemp-checkAppFileDir b/unitproc/bktemp-checkAppFileDir index 6059be6..d2f58d2 100644 --- a/unitproc/bktemp-checkAppFileDir +++ b/unitproc/bktemp-checkAppFileDir @@ -94,13 +94,14 @@ checkdir() { displayMissing() { # Desc: Displays missing apps, files, and dirs # Usage: displayMissing - # Version 0.1.1 + # Version 1.0.0 # Input: associative arrays: appRollCall, fileRollCall, dirRollCall # Output: stderr: messages indicating missing apps, file, or dirs + # Output: returns exit code 0 if nothing missing; 1 otherwise # Depends: bash 5, checkAppFileDir() local missingApps value appMissing missingFiles fileMissing local missingDirs dirMissing - + #==BEGIN Display errors== #===BEGIN Display Missing Apps=== missingApps="Missing apps :"; @@ -154,6 +155,13 @@ displayMissing() { #===END Display Missing Directories=== #==END Display errors== + #==BEGIN Determine function return code=== + if [ "$appMissing" == "true" ] || [ "$fileMissing" == "true" ] || [ "$dirMissing" == "true" ]; then + return 1; + else + return 0; + fi + #==END Determine function return code=== } # Display missing apps, files, dirs #===END Declare local script functions=== @@ -162,9 +170,16 @@ displayMissing() { #==BEGIN sample code== if checkapp cat; then echo "cat found."; fi; if checkapp gpg; then echo "gpg found."; fi; +if displayMissing 1>/dev/null 2>&1; then + echo "Nothing missing so far..."; +fi; + if checkapp emaaaacs; then echo "emaaaacs found."; fi; sleep 1; -displayMissing; +if ! displayMissing 1>/dev/null 2>&1; then + echo "Something is missing!"; + displayMissing; +fi; #==END sample code== # Author: Steven Baltaktei Sandoval