title: How to sanitize user input in Bash
body: <p>I am writing a script in bash which will prompt the user for two inputs. These inputs are assigned to the variables 'TO_SCHEMA' and 'FROM_SCHEMA' respectively.</p>
  
  <p>I need a way to verify proper input. My requirements are as follows:</p>
  
  <p>Each variable will have 3 acceptable values. They are the same values for both variables, but both variables must be in this list of three, and they cannot be the same value.</p>
  
  <p>So if the values are 'myco', 'myco_int', and 'teambatch', then both variables must be one of those values, but they can't be the same.</p>
  
  <pre><code>${TO_SCHEMA} = myco &amp;&amp; ${FROM_SCHEMA} = myco_int
     Pass
  
  ${TO_SCHEMA} = myco_int &amp;&amp; ${FROM_SCHEMA} = myco_int
     Fail
  
  ${TO_SCHEMA} = mco &amp;&amp; ${FROM_SCHEMA} = myco_int
     Fail
  
  ${TO_SCHEMA} = myco &amp;&amp; ${FROM_SCHEMA} = donkey
     Fail
  </code></pre>
  
  <p>How can I accomplish this? </p>
  
  <p>I began with an if statement full of AND and OR operators, but they got ugly fast. My experience with regex is limited, and my experience with sed and awk is non-existent, but I'm willing to learn and try any of that.
  Any help would be appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>I should also mention that this script is just for a somewhat small tedious one off task I have to do a lot at work that I would love to automate. If I'm not the one using it, then someone on my team will be. So this input checking is a want and not a need. It's not the end of the world if the script breaks because of bad input. I would just like it to handle bad input more elegantly.</p>
  
  <p>EDIT AGAIN:
  I appreciate everyone's suggestions, but I have to make some clarifications. The values won't actually be schema 1,2 and 3. I'm not allowed to provide proper names for security reasons, but I'm changing them to values more similar to the real ones. </p>