title: Building simple calculator in BASH
body: <p>I am learning Bash Shell Scripting as a section from the Linux Foundation LFS101x.2 and there is a Lab to create a simple Bash calculator.
  The Lab details are found here:
  <a href="https://courses.edx.org/asset-v1:LinuxFoundationX+LFS101x.2+1T2015+type@asset+block/BashShellScripting.pdf" rel="nofollow">Lab 5</a></p>
  
  <p>I'm trying to run the script by:</p>
  
  <pre><code>$ ./bashShellScriptingLab5.sh s 15 5
  </code></pre>
  
  <p>The error message is:</p>
  
  <pre><code>Welcome to Calculator!
  ./bashShellScriptingLab5.sh: line 39: syntax error near unexpected token `exit'
  ./bashShellScriptingLab5.sh: line 39: ` exit 0'
  </code></pre>
  
  <p>Here is my bashShellScriptingLab5.sh:</p>
  
  <pre><code>#!/bin/bash
  
  echo "Welcome to Calculator!"
  
  if [ $# != 3 ];
  then
          echo "Usage:"
          echo "Please enter a/s/m/d and two integers"
          exit 1
  fi
  
  addition () {
          echo "The result of adding " + $2 + " and " + $3 + " is:"
          d = expr $2 + $3
          echo $d
  }
  
  subtraction () {
          echo "The result of subtracting " + $2 + " and " + $3 + " is:"
          d = expr $2 - $3
          echo $d
  }
  
  multiplication () {
          echo "The result of multiply " + $2 + " and " + $3 + " is:"
          d = expr $2 * $3
          echo $d
  }
  
  division () {
          echo "The result of dividing " + $2 + " and " + $3 + " is:"
          d = expr $2 / $3
          echo $d
  }
  
  if [[ "$1" = "a" ]]
  then
          addition()
          exit 0
  elif [[ "$1" = "s" ]]
  then
          subtraction()
          exit 0
  elif [[ "$1" = "m" ]]
  then
          subtraction()
          exit 0
  elif [[ "$1" = "d" ]]
  then
          division()
          exit 0
  else
          echo "Usage:"
          echo "Please enter a/s/m/d and two integers"
          exit 1
  fi
  </code></pre>