extglob changes the way certain characters are parsed. It is necessary to have a newline (not just a semicolon) between shopt -s extglob and any subsequent commands to use it.You cannot enable extended globs inside a group command that uses them, because the entire block is parsed before the shopt is evaluated. Note that the typical function body is a group command. An unpleasant workaround could be to use a subshell command list as the function body.
Therefore, if you use this option in a script, it is best put right under the shebang line.
Toggle line numbers
1 #!/usr/bin/env bash
2 shopt -s extglob # and others, such as nullglob dotglob
3
Comments
Post a Comment