title: shell matching a pattern using a case-statement which is stored inside a variable
body: <p>I am trying to match a pattern with a case-statement where the pattern is stored inside a variable. Here is a minimal example:</p>
  
  <pre><code>PATTERN="foo|bar|baz|bla"
  
  case "foo" in
      ${PATTERN})
          printf "matched\n"
          ;;
      *)
          printf "no match\n"
          ;;
  esac
  </code></pre>
  
  <p>Unfortunately the "|" seems to be escaped (interestingly "*" or "?" are not). How do I get this to work, i.e. to match "foo"? I need to store the pattern in a variable because it is constructed dynamically. This needs to work on a POSIX compatible shell.</p>