telegram-bot-bash/examples/calc.sh

35 lines
976 B
Bash
Raw Normal View History

2019-04-14 18:30:59 +00:00
#!/bin/bash
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
2019-04-22 18:34:43 +00:00
#### $$VERSION$$ v0.70-dev2-0-g4fff4c3
2019-04-14 18:30:59 +00:00
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
export 'LC_ALL=C.UTF-8'
export 'LANG=C.UTF-8'
export 'LANGUAGE=C.UTF-8'
unset IFS
# set -f # if you are paranoid use set -f to disable globbing
echo 'Starting Calculator ...'
echo 'Enter first number.'
read -r A
echo 'Enter second number.'
read -r B
echo 'Select Operation: mykeyboardstartshere [ "Addition" , "Subtraction" , "Multiplication" , "Division" , "Cancel" ]'
2019-04-14 18:30:59 +00:00
read -r opt
echo -n 'Result: '
case $opt in
2019-04-16 11:29:49 +00:00
'add'* | 'Add'* ) res="$(( A + B ))" ;;
'sub'* | 'Sub'* ) res="$(( A - B ))" ;;
'mul'* | 'Mul'* ) res="$(( A * B ))" ;;
'div'* | 'Div'* ) res="$(( A / B ))" ;;
'can'* | 'Can'* ) res="abort!" ;;
2019-04-14 18:30:59 +00:00
* ) echo "unknown operator!";;
esac
2019-04-16 11:29:49 +00:00
echo "$res"
2019-04-14 18:30:59 +00:00
echo "Bye .."