#!/bin/sh -e
#
# bcalc - shortcut for mathematical calculations. converts num. such as 1.000,5
# better than just a `echo "$*" | bc -l` wrapper

# shellcheck disable=SC2312

calc="$(echo "$@" \
  | sed -e 's/p/+/g' -e 's/\.\(.*,\)/\1/g' -e 's/,/./g' -e 's/x/*/g' -e 's/m/-/g')"

bc -l <<EOF
$(printf 'scale=10;%s' "${calc}" | sed 's/\(\..*\)0\+$/\10/')
EOF
