I'm trying to construct a basic calculator, but using functions. I'm getting the error line 17: multiplication: command not found over and over again. So I guess I'm calling the functions wrong? What's the correct way of calling the function and passing parameters then?
#!/bin/bash
echo "Enter the operation:"
read operation
echo "Operand 1:"
read operand_1
echo "Operand 2:"
read operand_2
if [[ "$operation" == "+" ]]
then
addition
elif [[ "$operation" == "-" ]]
then
subtraction
elif [[ "$operation" == "*" ]]
then
multiplication
elif [[ "$operation" == "/" ]]
then
division
fi
addition()
{
result = $((operand_1+operand_2))
result $result
}
subtraction()
{
result = $((operand_1-operand_2))
result $result
}
multiplication()
{
result = $((operand_1*operand_2))
result $result
}
division()
{
result = $((operand_1/operand_2))
result $result
}
result()
{
echo "The result is $1"
}