From 2346594adcf0042bca68cf91c714dde12e770b16 Mon Sep 17 00:00:00 2001 From: deajan Date: Sat, 3 Sep 2016 13:30:38 +0200 Subject: [PATCH] Kept IsNumeric expand for variable variables --- dev/n_obackup.sh | 2 +- dev/ofunctions.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/n_obackup.sh b/dev/n_obackup.sh index 69c65f0..cc6a139 100755 --- a/dev/n_obackup.sh +++ b/dev/n_obackup.sh @@ -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 diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 85d4454..75863fb 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -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