Move shopt -s extglob up - it doesn't take effect until the next block