title: Dynamic case statement in bash
body: <p>I'm trying to figure out how to create a dynamic case statement in a bash script.</p>
  
  <p>For example, let's say I have the output of an awk statement with the following contents</p>
  
  <pre><code>red
  green
  blue
  </code></pre>
  
  <p>In this scenario, the output can change at any time.</p>
  
  <p>I'm trying to then execute different logic if a value is included in this awk output.</p>
  
  <p>So if the data above is in $list, then I'd conceptually like to do something like:</p>
  
  <pre><code>case "${my_var}" in
      $list)
          .....
      something_else)
          .....
  esac
  </code></pre>
  
  <p>I'm trying to use this to build a dynamic custom tab completion function (see <a href="http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_2" rel="nofollow">http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_2</a> for some background).</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks.</p>