Gistrec

Калькулятор

May 9th, 2018
232
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. while true
  4. do
  5.     first=""
  6.     operator=""
  7.     second=""
  8.  
  9.     read first operator second
  10.  
  11.     if [[ $first == "exit" ]]
  12.         then
  13.         echo "bye"
  14.         exit
  15.     fi
  16.  
  17.     if [[ $first == "" || $second == "" ]]
  18.         then
  19.         echo "error"
  20.         exit
  21.     fi
  22.  
  23.     if [ "$operator" != "+" ] && [ "$operator" != "-" ] && [ "$operator" != "*" ] && [ "$operator" != "/" ] && [ "$operator" != "%" ] && [ "$operator" != "**" ]
  24.         then
  25.         echo "error"
  26.         exit
  27.     fi
  28.  
  29.     let "result = $first $operator $second"
  30.  
  31.     echo $result
  32.  
  33. done
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment