Added HasData and IsEmpty function

This commit is contained in:
Michael Boelen 2017-04-23 20:19:18 +02:00
parent a04b2da851
commit 2340e7bbbc
No known key found for this signature in database
GPG Key ID: 26141F77A09D7F04
1 changed files with 35 additions and 0 deletions

View File

@ -50,12 +50,14 @@
# FileIsEmpty Check if a file is empty
# FileIsReadable Check if a file is readable or directory accessible
# GetHostID Retrieve an unique ID for this host
# HasData Checks for data in variable
# InsertSection Insert a section block
# InsertPluginSection Insert a section block for plugins
# IsContainer Determine if program runs in a container
# IsDebug Check if --debug is used
# IsDeveloperMode Check if --developer is used
# IsDeveloperVersion Check if program is a developer release
# IsEmpty Check for empty result or variable
# IsNotebook System detection
# IsOwnedByRoot Determine if file or directory is owned by root
# IsRunning Check if a process is running
@ -1090,6 +1092,22 @@
fi
}
################################################################################
# Name : HasData()
# Description : Check for a filled variable
#
# Returns : 0 = True, 1 = False
# Usage : if HasData "${FIND}"; then
################################################################################
HasData() {
if [ $# -eq 1 ]; then
if [ ! -z "$1" ]; then return 0; else return 1; fi
else
ExitFatal "Function HasData called without parameters - look in log to determine where this happened, or use sh -x lynis to see all details."
fi
}
################################################################################
# Name : InsertSection()
@ -1189,6 +1207,23 @@
}
################################################################################
# Name : IsEmpty()
# Description : Check for variable that has no data in it
#
# Returns : 0 = True, 1 = False
# Usage : if IsEmpty "${FIND}"; then
################################################################################
IsEmpty() {
if [ $# -eq 1 ]; then
if [ -z "$1" ]; then return 0; else return 1; fi
else
ExitFatal "Function IsEmpty called without parameters - look in log to determine where this happened, or use sh -x lynis to see all details."
fi
}
################################################################################
# Name : IsRunning()
# Description : Check if a process is running