How do I use a glob with parentheses in Zsh?

This has nothing to do with shell options. Rather, it depends on what shebang you have in your executable file.

When you run a script as an executable (instead of source-ing it or running it as a function), it runs in a separate sub-shell and not in your top-level shell. A sub-shell inherits its parent's environment (that is, exported parameters), but not any shell options. Instead, the shebang dictates which shell it runs in and with which options.

If the shebang is #!/bin/zsh, it will start a Zsh sub-shell with default options, then read commands from /etc/zshenv and $ZDOTDIR/.zshenv, and then from your script.

Likewise, if the shebang is #!/bin/bash, your script will actually run in Bash, and not in Zsh.

Finally, if the shebang is #!/bin/sh, it depends on your OS. On macOS, there is a symlink /private/var/select/sh that points to the shell executable to use when the shebang is #!/bin/sh. (Type man 1 sh for more info.) By default, that shell is Bash, and not Zsh, even if you have changed your login shell to Zsh. The only way to change it is to change that symlink.

But even if you make /private/var/select/sh point to the Zsh executable, if you run your script with a #!/bin/sh shebang, Zsh will not run in "native mode". Instead, it will run in sh emulation mode, which toggles a number of options that are significantly different from the Zsh defaults.

Parentheses are basic glob syntax in Zsh. However, they are not in Bash. So, my guess is, your script is actually running in Bash, because of the shebang.


So, anyway, long story short: Save yourself the trouble and don't run your script as an executable. Rather, what is usually the most convenient in Zsh, is to add your script's parent dir to your $fpath and then autoload your script as a function.