true_value: assume false if value not defined

This commit is contained in:
Jason Wood 2021-04-27 18:15:10 -05:00
parent 3b5c0e1d89
commit f397a46938
No known key found for this signature in database
GPG Key ID: A1946B71FB2255C1

7
msctl
View File

@ -358,14 +358,21 @@ getJavaMemory() {
true_value() {
local VALUE
VALUE=$(echo "$1" | tr '[:upper:]' '[:lower:]')
# Look for TRUE values.
if [ "$VALUE" = "1" ] || [ "$VALUE" = "true" ] || [ "$VALUE" = "yes" ] || [ "$VALUE" = "on" ]; then
# Return a true value (success).
return 0
fi
# Look for FALSE values.
if [ "$VALUE" = "0" ] || [ "$VALUE" = "false" ] || [ "$VALUE" = "no" ] || [ "$VALUE" = "off" ]; then
# Return a false value (failure).
return 1
fi
# Assume FALSE if value is not defined.
if [ "$VALUE" = "" ]; then
# Return a false value (failure).
return 1
fi
printf "Invalid true/false value: \"$1\"\n" >&2
# Return a false value (failure) in case of invalid true/false input.
return 1