title: Matching brackets inside a regular expression does not work in bash
body: <p>I defined a function that prints <code>yes</code> if its first argument contains  <code>a</code>, <code>b</code> or <code>c</code>:</p>
  
  <pre><code>$ func() { [[ $1 =~ [abc] ]] &amp;&amp; echo yes; }
  $ func xyz
  $ func xaz
  yes
  $ func xbz
  yes
  $ func xcz
  yes
  </code></pre>
  
  <p>Now I would like to detect <code>[</code>, <code>]</code> or <code>*</code> so I tried:</p>
  
  <pre><code>func() { [[ $1 =~ [\[\]*] ]] &amp;&amp; echo yes; }
  $ func x*z
  $ func x[z
  $ func x]z
  yes
  </code></pre>
  
  <p>This is only seems to work for <code>]</code>. I also tried <code>set -f</code> to disable glob expansion but got same results. </p>