Kept IsNumeric expand for variable variables

This commit is contained in:
deajan 2016-09-03 13:30:38 +02:00
parent cd3da2d589
commit 2346594adc
2 changed files with 3 additions and 3 deletions

View File

@ -146,7 +146,7 @@ function CheckCurrentConfig {
# Check all variables that should contain a numerical value >= 0
declare -a num_vars=(BACKUP_SIZE_MINIMUM SQL_WARN_MIN_SPACE FILE_WARN_MIN_SPACE SOFT_MAX_EXEC_TIME_DB_TASK HARD_MAX_EXEC_TIME_DB_TASK COMPRESSION_LEVEL SOFT_MAX_EXEC_TIME_FILE_TASK HARD_MAX_EXEC_TIME_FILE_TASK BANDWIDTH SOFT_MAX_EXEC_TIME_TOTAL HARD_MAX_EXEC_TIME_TOTAL ROTATE_SQL_COPIES ROTATE_FILE_COPIES KEEP_LOGGING MAX_EXEC_TIME_PER_CMD_BEFORE MAX_EXEC_TIME_PER_CMD_AFTER)
for i in "${num_vars[@]}"; do
test="if [ $(IsInteger \"\$$i\") -eq 0 ]; then Logger \"Bogus $i value defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
test="if [ $(IsNumericExpand \"\$$i\") -eq 0 ]; then Logger \"Bogus $i value defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
eval "$test"
done

View File

@ -837,7 +837,7 @@ function EscapeSpaces {
echo "${string// /\\ }"
}
function IsNumericOld {
function IsNumericExpand {
eval "local value=\"${1}\"" # Needed eval so variable variables can be processed
local re="^-?[0-9]+([.][0-9]+)?$"
@ -861,7 +861,7 @@ function IsNumeric {
function IsInteger {
local value="${1}"
if [[ $value =~ ^[0-9]?$ ]]; then
if [[ $value =~ ^[0-9]+$ ]]; then
echo 1
else
echo 0