Initialize some vars to allow strict mode to work

IsRunning():
To check if $users is empty in strict mode we need the var to be initializez

ReportException:
Some test call this function without the second parameter, this is not allowed in strict mode if we don't initialize the variable
This commit is contained in:
David 2019-07-17 23:16:47 +02:00 committed by GitHub
parent 250fb965d3
commit 06413994cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1400,7 +1400,8 @@
# AIX does not fully support pgrep options, so using ps instead # AIX does not fully support pgrep options, so using ps instead
if [ -n "${PGREPBINARY}" -a ! "${OS}" = "AIX" ]; then if [ -n "${PGREPBINARY}" -a ! "${OS}" = "AIX" ]; then
# When --user is used, perform a search using the -u option # When --user is used, perform a search using the -u option
if [ -n "${users}" ]; then # Initialize users for strict mode
if [ -n "${users:-}" ]; then
for u in "${users}"; do for u in "${users}"; do
user_uid=$(getent passwd ${u} 2> /dev/null | ${AWKBINARY} -F: '{print $3}') user_uid=$(getent passwd ${u} 2> /dev/null | ${AWKBINARY} -F: '{print $3}')
# Only perform search if user exists and we had no match yet # Only perform search if user exists and we had no match yet
@ -2641,8 +2642,9 @@
# Log exceptions # Log exceptions
ReportException() { ReportException() {
Report "exception_event[]=$1|$2|" # Allow this function with only 1 parameter in strict mode with ${2-Text}
LogText "Exception: test has an exceptional event ($1) with text $2" Report "exception_event[]=$1|${2-NoInfo}|"
LogText "Exception: test has an exceptional event ($1) with text ${2-NoText}"
} }