title: Bash:Else not working in if/else statement in case statement
body: <p>I am trying to check if a user types multiple arguments in a command line using case and if/else statements. What's wrong is that I keep getting the default case instead of the same command, but with 2 more arguments. For instance, one of my conditions is:</p>
  
  <pre><code>del)
      if [ -z "$2" ] || [ -z "$3" ]
      then
              echo "Usage: removes a file"
      else
      echo "using Bash command: rm $2 $3"
      rm $2 $3
      echo done
      fi
  </code></pre>
  
  <p>prints the first condition, but if I type, say, del aaa bbb, I get the default case, which is:</p>
  
  <pre><code>echo "ERROR: Unrecognized command"
  </code></pre>
  
  <p>I'm also using this to read a user's input, if that helps.</p>
  
  <pre><code>read -p "wcl&gt; " -r wcl $2 $3
  </code></pre>
  
  <p>I don't really know if there's a better way to solve this without scrapping all my code and starting from scratch.
  This is the full code:</p>
  
  <pre><code>#!/bin/bash
  #use read command
  
  echo Welcome to the Windows Command Line simulator!
  echo Enter your commands below
  while true
  do
  read -p "wcl&gt; " -r wcl $2 $3
      case  $wcl  in
       dir)
      echo "using Bash command: ls  $2 $3"
      ls
      continue 
              ;;
      copy)
      FILE="$2"
      if [ "$#" -ne 3 ]
      then
           echo "Usage: copy sourcefile destinationfile"
      else
      echo "using Bash command: cp $2 $3"
      if [ -f "$FILE" ]
      then
      cp $2 $3
      else
      echo "cannot stat $FILE: No such file or directory"&gt;&amp;2
      fi
      echo done
      fi
      continue
              ;;
      del)
      if [ -z "$2" ] || [ -z "$3" ]
      then
              echo "Usage: removes a file"
      else
      echo "using Bash command: rm $2 $3"
      rm $2 $3
      echo done
      fi
      continue
              ;;
      move)
      if [ -z "$2" ] || [ -z "$3" ]
      then
              echo "Usage: moves a file to another file name and location"
      else
      echo "using Bash command: mv $2 $3"
      mv $2 $3
      echo done
      fi
      continue
              ;;
      rename)
      if [ -z "$2" ] || [ -z "$3" ]
      then
              echo "Usage: renames a file"
      else
      echo "using Bash command: mv $2 $3"
      mv $2 $3
      echo done
      fi
      continue
              ;;
      ipconfig)
              ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1
      continue
              ;;
        exit)
              echo "Goodbye"
              exit 1
              ;;
      ^c)
              echo "Goodbye"
              exit 1
              ;;
  *)
              echo "ERROR: Unrecognized command"
      continue
  esac
  done
  </code></pre>