title: how do I get bash globbing to work in script
body: <p>I am trying to convert some of my ksh93 scripts to bash in cygwin. I have found 2 things right now that give me trouble. The first is a function I put in .bashrc was not recognized in the script. I put the function in the script to get around that. The second is that it won't glob like it does in ksh93. Setting <code>extglob</code> didn't seem to help.  Here is what I have done:</p>
  
  <pre><code>#! /bin/bash
  
  rep() {
          perl -E 'say "'"$1"'" x '$2
          # seq -s"$1" $2|tr -d '[:digit:]'
  }
  
  # added these 2 lines for testing
  shopt -s extglob
  shopt extglob
  
  ziptext="Monthly files for $(date --date="$(date +%Y-%m-15) -1 month" +'%B %Y')"
  equals4=$(rep = $((${#ziptext} + 6)))
  equals="$(rep = ${#ziptext})"
  spaces="$(rep ' ' ${#ziptext})"
  
  # added these 2 lines for testing
  ls -l 20[0-9][0-9]' Monthly Data - review.xlsx'
  pwd
  
  echo "
  
    $equals4
    =  $equals  =
    =  $spaces  =
    =  $ziptext  =
    =  $spaces  =
    =  $equals  =
    $equals4\n\n\n" | zip -9 -u -z \
          20[0-9][0-9]' Monthly Data - review.xlsx' \
          20[0-9][0-9]' Monthly Tables - review.xlsx'
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>extglob         on
  ls: cannot access '20[0-9][0-9] Monthly Data - review.xlsx': No such file or directory
  /cygdrive/c/reports
          zip warning: 20[0-9][0-9] Monthly Data - review.xlsx not found or empty
          zip warning: name not matched: 20[0-9][0-9] Monthly Tables - review.xlsx
  </code></pre>
  
  <p>From the shell, doing</p>
  
  <pre><code>ls 20[0-9][0-9]' Monthly Data - review.xlsx' \
      20[0-9][0-9]' Monthly Tables - review.xlsx'
  </code></pre>
  
  <p>Results in</p>
  
  <pre><code>'2019 Monthly Data - Review.xlsx'*  '2019 Monthly Tables - Review.xlsx'*
  </code></pre>
  
  <p>What setting am I missing out on to get this to work like it did in ksh93?</p>