collection of python libs developed for testing purposes

calc.sh 361B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. op=$1
  3. a=$2
  4. b=$3
  5. result=
  6. usage() {
  7. echo "usage: $(basename $0) operator a b"
  8. exit 1
  9. }
  10. case $op in
  11. add)
  12. result=$(( a + b ))
  13. ;;
  14. sub)
  15. result=$(( a - b ))
  16. ;;
  17. mul)
  18. result=$(( a * b ))
  19. ;;
  20. div)
  21. result=$(( a / b ))
  22. ;;
  23. *)
  24. usage
  25. ;;
  26. esac
  27. echo $result