From 658d99f86746f8c6bbe40129827ef476fd3773a6 Mon Sep 17 00:00:00 2001 From: olli Date: Fri, 3 Nov 2023 15:06:11 +0100 Subject: [PATCH] gaboshlib/g_num_is_lower.sh aktualisiert --- gaboshlib/g_num_is_lower.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/gaboshlib/g_num_is_lower.sh b/gaboshlib/g_num_is_lower.sh index 03c4e82..75584ac 100644 --- a/gaboshlib/g_num_is_lower.sh +++ b/gaboshlib/g_num_is_lower.sh @@ -1,3 +1,32 @@ +function g_num_is_lower_equal { + + local f_num=$1 + local f_checkhigher=$2 + + # Check for integer (can be done with bash itself) + if [[ ${f_num} =~ ^[0-9]+$ ]] && [[ ${f_checkhigher} =~ ^[0-9]+$ ]] + then + # Check which is the low (from) and the high (to) number + if [ "${f_num}" -le "${f_checkhigher}" ] + then + return 0 + else + return 1 + fi + fi + + # Check for valid number + g_num_valid_number "$f_num" "$f_checkhigher" || return 1 + + if [ $(g_calc "${f_num} <= ${f_checkhigher}") -ne 0 ] + then + return 0 + else + return 1 + fi +} + + function g_num_is_lower { local f_num=$1 @@ -7,7 +36,7 @@ function g_num_is_lower { if [[ ${f_num} =~ ^[0-9]+$ ]] && [[ ${f_checkhigher} =~ ^[0-9]+$ ]] then # Check which is the low (from) and the high (to) number - if [ "${f_num}" -gt "${f_checkhigher}" ] + if [ "${f_num}" -lt "${f_checkhigher}" ] then return 0 else