fixes
This commit is contained in:
parent
2563371b0e
commit
f73f0ea572
@ -52,5 +52,5 @@ function g_calc {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# store result
|
# store result
|
||||||
g_calc_result="${g_sed_out}"
|
g_calc_result=$g_sed_out
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,19 @@ function g_num_is_between {
|
|||||||
local f_between2=$3
|
local f_between2=$3
|
||||||
|
|
||||||
# Check for integer (can be done with bash itself)
|
# Check for integer (can be done with bash itself)
|
||||||
if [[ ${f_num} =~ ^[0-9]+$ ]] && [[ ${f_between1} =~ ^[0-9]+$ ]] && [[ ${f_between2} =~ ^[0-9]+$ ]]
|
if [[ $f_num =~ ^[0-9]+$ ]] && [[ $f_between1 =~ ^[0-9]+$ ]] && [[ $f_between2 =~ ^[0-9]+$ ]]
|
||||||
then
|
then
|
||||||
# Check which is the low (from) and the high (to) number
|
# Check which is the low (from) and the high (to) number
|
||||||
if [ "${f_between1}" -lt "${f_between2}" ]
|
if [ $f_between1 -lt $f_between2 ]
|
||||||
then
|
then
|
||||||
local f_from=${f_between1}
|
local f_from=$f_between1
|
||||||
local f_to=${f_between2}
|
local f_to=$f_between2
|
||||||
else
|
else
|
||||||
local f_from=${f_between2}
|
local f_from=$f_between2
|
||||||
local f_to=${f_between1}
|
local f_to=$f_between1
|
||||||
fi
|
fi
|
||||||
# Check if given number is in or out range
|
# Check if given number is in or out range
|
||||||
if [ ${f_num} -lt ${f_from} ] || [ ${f_num} -gt ${f_to} ]
|
if [ $f_num -lt $f_from ] || [ $f_num -gt $f_to ]
|
||||||
then
|
then
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
@ -29,21 +29,21 @@ function g_num_is_between {
|
|||||||
g_num_valid_number "$f_num" "$f_between1" "$f_between2" || return 1
|
g_num_valid_number "$f_num" "$f_between1" "$f_between2" || return 1
|
||||||
|
|
||||||
# Check which is the low (from) and the high (to) number
|
# Check which is the low (from) and the high (to) number
|
||||||
g_calc "${f_between1} < ${f_between2}"
|
g_calc "$f_between1 < $f_between2"
|
||||||
if [ ${g_calc_result} -ne 0 ]
|
if [ "$g_calc_result" -ne 0 ]
|
||||||
then
|
then
|
||||||
local f_from=${f_between1}
|
local f_from=$f_between1
|
||||||
local f_to=${f_between2}
|
local f_to=$f_between2
|
||||||
else
|
else
|
||||||
local f_from=${f_between2}
|
local f_from=$f_between2
|
||||||
local f_to=${f_between1}
|
local f_to=$f_between1
|
||||||
fi
|
fi
|
||||||
# Check if given number is in or out range
|
# Check if given number is in or out range
|
||||||
g_calc "${f_num} < ${f_from}"
|
g_calc "$f_num < $f_from"
|
||||||
local g_calc_result_from="${g_calc_result}"
|
local g_calc_result_from="$g_calc_result"
|
||||||
g_calc "${f_num} > ${f_to}"
|
g_calc "$f_num > $f_to"
|
||||||
local g_calc_result_to="${g_calc_result}"
|
local g_calc_result_to="$g_calc_result"
|
||||||
if [ ${g_calc_result_from} -ne 0 ] || [ ${g_calc_result_to} -ne 0 ]
|
if [ "$g_calc_result_from" -ne 0 ] || [ "$g_calc_result_to" -ne 0 ]
|
||||||
then
|
then
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
|
@ -19,7 +19,7 @@ function g_num_is_higher_equal {
|
|||||||
g_num_valid_number "$f_num" "$f_checkhigher" || return 1
|
g_num_valid_number "$f_num" "$f_checkhigher" || return 1
|
||||||
|
|
||||||
g_calc "${f_num} >= ${f_checkhigher}"
|
g_calc "${f_num} >= ${f_checkhigher}"
|
||||||
if [ ${g_calc_result} -ne 0 ]
|
if [ "${g_calc_result}" -ne 0 ]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
@ -46,9 +46,9 @@ function g_num_is_higher {
|
|||||||
|
|
||||||
# Check for valid number
|
# Check for valid number
|
||||||
g_num_valid_number "$f_num" "$f_checkhigher" || return 1
|
g_num_valid_number "$f_num" "$f_checkhigher" || return 1
|
||||||
|
|
||||||
g_calc "${f_num} > ${f_checkhigher}"
|
g_calc "${f_num} > ${f_checkhigher}"
|
||||||
if [ ${g_calc_result} -ne 0 ]
|
if [ "${g_calc_result}" -ne 0 ]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
@ -19,7 +19,7 @@ function g_num_is_lower_equal {
|
|||||||
g_num_valid_number "$f_num" "$f_checklower" || return 1
|
g_num_valid_number "$f_num" "$f_checklower" || return 1
|
||||||
|
|
||||||
g_calc "${f_num} <= ${f_checklower}"
|
g_calc "${f_num} <= ${f_checklower}"
|
||||||
if [ ${g_calc_result} -ne 0 ]
|
if [ "${g_calc_result}" -ne 0 ]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
@ -49,7 +49,7 @@ function g_num_is_lower {
|
|||||||
g_num_valid_number "$f_num" "$f_checklower" || return 1
|
g_num_valid_number "$f_num" "$f_checklower" || return 1
|
||||||
|
|
||||||
g_calc "${f_num} < ${f_checklower}"
|
g_calc "${f_num} < ${f_checklower}"
|
||||||
if [ ${g_calc_result} -ne 0 ]
|
if [ "${g_calc_result}" -ne 0 ]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
function g_traceback {
|
function g_traceback {
|
||||||
local deptn=${#FUNCNAME[@]}
|
local deptn=${#FUNCNAME[@]}
|
||||||
|
local i
|
||||||
for ((i=1; i<$deptn; i++)); do
|
for ((i=1; i<$deptn; i++)); do
|
||||||
local func="${FUNCNAME[$i]}"
|
local func="${FUNCNAME[$i]}"
|
||||||
local line="${BASH_LINENO[$((i-1))]}"
|
local line="${BASH_LINENO[$((i-1))]}"
|
||||||
@ -7,4 +8,5 @@ function g_traceback {
|
|||||||
printf '%*s' $i '' # indent
|
printf '%*s' $i '' # indent
|
||||||
echo "at: $func, $src, line $line" 1>&2
|
echo "at: $func, $src, line $line" 1>&2
|
||||||
done
|
done
|
||||||
}
|
echo "$@" 1>&2
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user