scripts/functions_korn/calc

16 lines
317 B
Plaintext

function calc {
# Comprobar si el comando bc está instalado
if ! command -v bc >/dev/null 2>&1; then
print "Error: bc no está instalado." >&2
return 1
fi
# Comprobar si se proporcionó una expresión matemática
if [[ $# -eq 0 ]]; then
print "Uso: calc EXPRESIÓN" >&2
return 1
fi
bc -l <<<"$*"
}