diff --git a/gaboshlib/g_calc.sh b/gaboshlib/g_calc.sh index 842aa81..d21ac13 100644 --- a/gaboshlib/g_calc.sh +++ b/gaboshlib/g_calc.sh @@ -52,5 +52,5 @@ function g_calc { fi # store result - g_calc_result="${g_sed_out}" + g_calc_result=$g_sed_out } diff --git a/gaboshlib/g_num_is_between.sh b/gaboshlib/g_num_is_between.sh index f9a7764..ec36eab 100644 --- a/gaboshlib/g_num_is_between.sh +++ b/gaboshlib/g_num_is_between.sh @@ -5,19 +5,19 @@ function g_num_is_between { local f_between2=$3 # 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 # Check which is the low (from) and the high (to) number - if [ "${f_between1}" -lt "${f_between2}" ] + if [ $f_between1 -lt $f_between2 ] then - local f_from=${f_between1} - local f_to=${f_between2} + local f_from=$f_between1 + local f_to=$f_between2 else - local f_from=${f_between2} - local f_to=${f_between1} + local f_from=$f_between2 + local f_to=$f_between1 fi # 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 return 1 else @@ -29,21 +29,21 @@ function g_num_is_between { g_num_valid_number "$f_num" "$f_between1" "$f_between2" || return 1 # Check which is the low (from) and the high (to) number - g_calc "${f_between1} < ${f_between2}" - if [ ${g_calc_result} -ne 0 ] + g_calc "$f_between1 < $f_between2" + if [ "$g_calc_result" -ne 0 ] then - local f_from=${f_between1} - local f_to=${f_between2} + local f_from=$f_between1 + local f_to=$f_between2 else - local f_from=${f_between2} - local f_to=${f_between1} + local f_from=$f_between2 + local f_to=$f_between1 fi # Check if given number is in or out range - g_calc "${f_num} < ${f_from}" - local g_calc_result_from="${g_calc_result}" - g_calc "${f_num} > ${f_to}" - local g_calc_result_to="${g_calc_result}" - if [ ${g_calc_result_from} -ne 0 ] || [ ${g_calc_result_to} -ne 0 ] + g_calc "$f_num < $f_from" + local g_calc_result_from="$g_calc_result" + g_calc "$f_num > $f_to" + local g_calc_result_to="$g_calc_result" + if [ "$g_calc_result_from" -ne 0 ] || [ "$g_calc_result_to" -ne 0 ] then return 1 else diff --git a/gaboshlib/g_num_is_higher.sh b/gaboshlib/g_num_is_higher.sh index b619cef..5a15dd3 100644 --- a/gaboshlib/g_num_is_higher.sh +++ b/gaboshlib/g_num_is_higher.sh @@ -19,7 +19,7 @@ function g_num_is_higher_equal { g_num_valid_number "$f_num" "$f_checkhigher" || return 1 g_calc "${f_num} >= ${f_checkhigher}" - if [ ${g_calc_result} -ne 0 ] + if [ "${g_calc_result}" -ne 0 ] then return 0 else @@ -46,9 +46,9 @@ function g_num_is_higher { # Check for valid number g_num_valid_number "$f_num" "$f_checkhigher" || return 1 - + g_calc "${f_num} > ${f_checkhigher}" - if [ ${g_calc_result} -ne 0 ] + if [ "${g_calc_result}" -ne 0 ] then return 0 else diff --git a/gaboshlib/g_num_is_lower.sh b/gaboshlib/g_num_is_lower.sh index 806478e..7d415cd 100644 --- a/gaboshlib/g_num_is_lower.sh +++ b/gaboshlib/g_num_is_lower.sh @@ -19,7 +19,7 @@ function g_num_is_lower_equal { g_num_valid_number "$f_num" "$f_checklower" || return 1 g_calc "${f_num} <= ${f_checklower}" - if [ ${g_calc_result} -ne 0 ] + if [ "${g_calc_result}" -ne 0 ] then return 0 else @@ -49,7 +49,7 @@ function g_num_is_lower { g_num_valid_number "$f_num" "$f_checklower" || return 1 g_calc "${f_num} < ${f_checklower}" - if [ ${g_calc_result} -ne 0 ] + if [ "${g_calc_result}" -ne 0 ] then return 0 else diff --git a/gaboshlib/g_traceback.sh b/gaboshlib/g_traceback.sh index a803edf..dab4faf 100644 --- a/gaboshlib/g_traceback.sh +++ b/gaboshlib/g_traceback.sh @@ -1,5 +1,6 @@ function g_traceback { local deptn=${#FUNCNAME[@]} + local i for ((i=1; i<$deptn; i++)); do local func="${FUNCNAME[$i]}" local line="${BASH_LINENO[$((i-1))]}" @@ -7,4 +8,5 @@ function g_traceback { printf '%*s' $i '' # indent echo "at: $func, $src, line $line" 1>&2 done -} \ No newline at end of file + echo "$@" 1>&2 +}