diff --git a/dabo/functions/currency_converter.sh b/dabo/functions/currency_converter.sh index 49ff90b..195614a 100644 --- a/dabo/functions/currency_converter.sh +++ b/dabo/functions/currency_converter.sh @@ -7,9 +7,9 @@ function currency_converter { local f_currency_target=$3 local f_currency_date=$4 - unset f_currency_converter_result - local f_reverse=false - local f_line f_rate f_histfile f_date_array f_stablecoin + unset f_currency_converter_result + + local f_line f_rate f_histfile f_date_array f_stablecoin f_reverse # get current date if none given [ -z "$f_currency_date" ] && printf -v f_currency_date '%(%Y-%m-%d %H:%M:%S)T' @@ -83,6 +83,7 @@ function currency_converter { [ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_day" "$f_histfile" | tail -n1) [ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_month" "$f_histfile" | tail -n1) [ -n "$f_line" ] && f_rate=$(echo "$f_line" | cut -d, -f2) + f_reverse=false if [ -n "$f_rate" ] then [[ $f_histfile =~ ${f_currency}${f_currency_target} ]] && f_reverse=true