#!/usr/bin/env bash

brt_calc() {
  local expr="${*:-}"
  if [[ -z "$expr" ]]; then
    brt_error 'Usage: brt -calc <expression>  (e.g. brt -calc "2 + 2 * 3")'
    exit 1
  fi

  if ! command -v bc &>/dev/null; then
    brt_error "bc is required for -calc"
    exit 1
  fi

  echo "$expr" | bc -l
}
