This commit is contained in:
olli 2024-06-04 15:13:00 +02:00
parent c0fe474c19
commit 398daf619f

View File

@ -7,9 +7,9 @@ function currency_converter {
local f_currency_target=$3 local f_currency_target=$3
local f_currency_date=$4 local f_currency_date=$4
unset f_currency_converter_result unset f_currency_converter_result
local f_reverse=false
local f_line f_rate f_histfile f_date_array f_stablecoin local f_line f_rate f_histfile f_date_array f_stablecoin f_reverse
# get current date if none given # get current date if none given
[ -z "$f_currency_date" ] && printf -v f_currency_date '%(%Y-%m-%d %H:%M:%S)T' [ -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_day" "$f_histfile" | tail -n1)
[ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_month" "$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) [ -n "$f_line" ] && f_rate=$(echo "$f_line" | cut -d, -f2)
f_reverse=false
if [ -n "$f_rate" ] if [ -n "$f_rate" ]
then then
[[ $f_histfile =~ ${f_currency}${f_currency_target} ]] && f_reverse=true [[ $f_histfile =~ ${f_currency}${f_currency_target} ]] && f_reverse=true