mirror of https://github.com/CISOfy/lynis.git
New function: Equals
This commit is contained in:
parent
16146aabc0
commit
1854e51e7e
|
@ -43,6 +43,7 @@
|
|||
# DisplayManual Output text to screen without any layout
|
||||
# DisplayToolTip Show a tip for improving usage of the tool
|
||||
# DisplayWarning Show a clear warning on screen
|
||||
# Equals Compares two strings
|
||||
# ExitClean Stop the program (cleanly), with exit code 0
|
||||
# ExitCustom Stop the program (cleanly), with custom exit code
|
||||
# ExitFatal Stop the program (cleanly), with exit code 1
|
||||
|
@ -627,6 +628,27 @@
|
|||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
# Name : Equals()
|
||||
# Description : Compare two strings
|
||||
#
|
||||
# Returns : (0 - True, 1 - False)
|
||||
# Usage : if Equals "${MYDIR}" "/etc"; then echo "Found"; else "Not found"; fi
|
||||
################################################################################
|
||||
|
||||
Equals() {
|
||||
RETVAL=1
|
||||
if [ $# -ne 2 ]; then ReportException "Equals" "Incorrect number of arguments for $0 function"; fi
|
||||
|
||||
# Strip any strange control characters
|
||||
INPUT1=$(echo $1 | tr -d '[:cntrl:]<>' | ${SEDBINARY} 's/__space__/ /g' | ${SEDBINARY} 's/:space:/ /g')
|
||||
INPUT2=$(echo $2 | tr -d '[:cntrl:]<>' | ${SEDBINARY} 's/__space__/ /g' | ${SEDBINARY} 's/:space:/ /g')
|
||||
if [ "${INPUT1}" = "${INPUT2}" ]; then RETVAL=0; fi
|
||||
|
||||
return ${RETVAL}
|
||||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
# Name : ExitClean()
|
||||
# Description : Perform a normal exit of the program, and clean up resources
|
||||
|
|
Loading…
Reference in New Issue