In older versions of GNU Bash extended patterns, such as “@(…)” are only available with the “extglob” shell option. As pointed out in [1] and [2], “extglob” must be enabled while parsing the code. Therefore the flag must be enabled at the beginning of the script and be reset to its original value at the end as to not hamper with other code on shell initialization.
[1] http://unix.stackexchange.com/questions/45957 [2] http://mywiki.wooledge.org/glob Reported by Sascha Lucas. --- autotools/build-bash-completion | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion index 359f7a8..8687254 100755 --- a/autotools/build-bash-completion +++ b/autotools/build-bash-completion @@ -639,6 +639,11 @@ def main(): buf = StringIO() sw = utils.ShellWriter(buf, indent=not options.compact) + # Remember original state of extglob and enable it (required for pattern + # matching; must be enabled while parsing script) + sw.Write("gnt_shopt_extglob=$(shopt -p extglob || :)") + sw.Write("shopt -s extglob") + WritePreamble(sw, not options.compact) # gnt-* scripts @@ -656,6 +661,10 @@ def main(): not options.compact, opts=burnin.OPTIONS, args=burnin.ARGUMENTS) + # Reset extglob to original value + sw.Write("[[ -n \"$gnt_shopt_extglob\" ]] && $gnt_shopt_extglob") + sw.Write("unset gnt_shopt_extglob") + print buf.getvalue() -- 1.7.6
