From 08fc39b7cb85791bb5ffb96d443439d3e8e36a7a Mon Sep 17 00:00:00 2001 From: olli Date: Fri, 3 Nov 2023 10:26:33 +0100 Subject: [PATCH] =?UTF-8?q?gaboshlib/g=5Fnum=5Fis=5Flower.sh=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gaboshlib/g_num_is_lower.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gaboshlib/g_num_is_lower.sh diff --git a/gaboshlib/g_num_is_lower.sh b/gaboshlib/g_num_is_lower.sh new file mode 100644 index 0000000..f5792f8 --- /dev/null +++ b/gaboshlib/g_num_is_lower.sh @@ -0,0 +1,27 @@ +function g_num_is_lower { + + 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}" -gt "${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 [ $(echo "${f_num} < ${f_checkhigher}" | bc) -ne 0 ] + then + return 0 + else + return 1 + fi +}