With *extglob* on, I want to match a variable against 

```
*( )x*

```

(In regex: `/^ *x.*/`)

This:

```
main(){
  shopt -s extglob
  local line=' x bar'
  case "$line" in
    *( )x*) ;;
    *) ;;
  esac
}
main "$@"

```

is giving me a syntax error. Either removing the extglob parentheses or moving `shopt -s extglob` outside of `main`, to the outer scope, fixes the problem.
Why? Why does the `shopt -s extglob` command need to be outside?