Não tenho certeza se há uma fonte mais autorizada (ou seja, página de manual / documentação oficial) sobre esse problema, mas encontrei um site que explica esse comportamento: link
Because the extglob option changes the way certain characters are parsed, it is necessary to have a newline (not just a semicolon) between the shopt command and any subsequent commands that use extended globs. Likewise, you cannot put shopt -s extglob inside a statement block that uses extended globs, because the block as a whole must be parsed when it's defined; the shopt command won't take effect until the block is evaluated, at which point it's too late. In fact as bash parses the entire statement block before evaluating any of it, you need to set extglob outside of the outermost block.